Can plugins define custom ways to load fixtures?
See original GitHub issueNot sure if this is a feature request or a documentation issue!
I would like to define fixtures in YAML files. I could write a yaml-loader fixture + use parametrize to give a filename to the loader, but it would be even better if I could instead write test_something(some_data)
+ some_data.yml
and have the data from the YAML file loaded and passed to the test function.
(I am not asking about a YAML test collector, as found in an example in the docs and in plugins like yamlwsgi.)
From reading docs and tickets, it is not clear to me if this is possible. It looks like pytest_runtest_setup might be able to transform a test function before it’s run, but the documentation on that hook is very scarce.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Writing plugins
pytest loads plugin modules at tool startup in the following way: by scanning the command line for the -p no:name option and blocking...
Read more >Load Fixtures from Cypress Custom Commands
We will look at fixtures, aliases, hooks, and custom commands. ... How to load or import fixtures to be used in the Cypress...
Read more >How to test cake3 plugins with fixtures - php
I tryed to create a custom bootstrap.php for testing but I cannot figure what has to be there. I copyed this one https://github.com/Xety/Cake3- ......
Read more >Modularizing Pytest Fixtures
However, how can we define test fixtures such that they are ... These plugins can then be loaded in a test file or...
Read more >Customizing your pytest test suite (part 2)
The quickest way to switch between different groups, based on the individual test item, is to create a fixture that returns a specific...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s interesting! Using module-level
__dir__
and__getattr__
I could even avoid mucking with globals. I will try this idea, thanks!I found this: https://github.com/pytest-dev/pytest/issues/2424#issuecomment-333387206 not sure if it implements exactly what you’re looking for but looks promising.
A little bit of hackery, but it looks like it works:
even threw in a little bit to make
pytest --fixtures
output work correctly: