Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Add package scoped fixtures #2283
Session level scoping is great for expensive setup steps but it doesn't cleanup until the end of the test run. If you are testing multiple packages with conflicting setups you are forced to invoke py.test multiple times, once per package. We would love to have package scoped fixtures - run setup/teardown once per package.
a package scoped fixture defined in
Why do you say that @RonnyPfannschmidt? I think it could follow the usual scoping rules: when a test function requests a package-scoped fixture and it doesn't exist, create it; tests execute as normal, until the
Of course we can't guarantee that for a specific package only one package-scoped fixture will be created for the lifetime of the test session given that plugins like
Just trying to get a clear picture of why you think this would need to change the structure of the collection.
Oh I agree.
We have a similar test structure:
Now the tests in the suite1 require an expensive setup, for instance they pull N items from a shared reservation pool of N+1 items. Then comes suite2 that needs to pull another M (M >> 1) items from the same pool, but there's not enough left because suite1's teardown has not executed yet. All "session" scoped teardowns execute after all tests have been executed.
Is there any chance we can revisit this? I volunteer to help if you point me in the right direction!