Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fixture scope documentation #538
The fixture documentation briefly mentions the possibility of a fixture with class scope in the beginning summary, but it isn't mentioned anywhere else in the document. I had to check the source code to see if this was possible.
Also, I didn't see any mention that the default scope was "function" - it was implied, but not explicit.
I think it would be helpful to include a full list of available scopes, and to explicitly say that function scope is default. Both of these things are included in the docstring for the fixture function in the source code:
I don't know I I should raise this as a different bug or keep it here. I wasn't able to find a solution for this in the documentaiton. I do have a set of unittests written using the python's unittest module. They are using the setUpModule() function to load a global variable with the shared "stuff" that is required to run the tests (including some http sesions).
When run normally my tests was running fine but with py.test they are failing. I patched it a little bit to make it run using the old pytest fixture functions (which happen not to have same names as unittest ones). Worked but only when not executed on multiple threads, and that's a feature I do want to use.
The documentation examples are useless in my case because I do have like 20 classes (unittest.TestCase) with 10 tests inside each class. Obviously I do not want to add a new parameter to each test.
Until now I used the class setUp() method to load the shared dictionare inside self.
I've read the documentation, and think the Sharing a fixture across tests in a module (or class/session) section makes this clear enough. Otherwise (this is a rough draft) how about: