Ensure tests can be executed using hypothesis >= 6 by suppressing
the function_scoped_fixture health check on test that uses a function
scope fixture in combination with @given.
Details
- Reviewers
vlorentz - Group Reviewers
Reviewers - Commits
- rDCORE76360cc7614f: tests: Drop hypothesis < 6 requirement
Diff Detail
- Repository
- rDCORE Foundations and core functionalities
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Event Timeline
Build is green
Patch application report for D5182 (id=18533)
Rebasing onto 576b104799...
Current branch diff-target is up to date.
Changes applied before test
commit a56ef76e37c4e4106352e52df50d005bc1d68c79 Author: Antoine Lambert <antoine.lambert@inria.fr> Date: Tue Mar 2 16:27:03 2021 +0100 tests: Drop hypothesis < 6 requirement Ensure tests can be executed using hypothesis >= 6 by suppressing the function_scoped_fixture health check on test that uses a function scope fixture in combination with @given.
See https://jenkins.softwareheritage.org/job/DCORE/job/tests-on-diff/198/ for more details.
mypy doesn't like it:
swh/web/tests/conftest.py:41: error: "Type[HealthCheck]" has no attribute "function_scoped_fixture"
You should probably add a # type: ignore
I did not grasp what this was about.
After checking [1], i'm a bit less hazy on what that particular health check is about.
Check if @given has been applied to a test with a pytest function-scoped fixture. Function-scoped fixtures run once for the whole function, not once per example, and this is usually not what you want. Because of this limitation, tests that need to need to set up or reset state for every example need to do so manually within the test itself, typically using an appropriate context manager.
So that might help others to inline it ^
What i grasp is that with hypothesis 6, that test was breaking. And as we don't care
here about reset in between tests, we can deactivate that check:
Suppress this health check only in the rare case that you are using a function-scoped fixture that does not need to be reset between individual examples, but for some reason you cannot use a wider fixture scope (e.g. session scope, module scope, class scope).
I can't reproduce the mypy error (neither the CI build), which version are you using ?
Build has FAILED
Patch application report for D5182 (id=18550)
Rebasing onto 576b104799...
Current branch diff-target is up to date.
Changes applied before test
commit 58f97df7c0cc1ef92ab657b05fc65c88bb6ac273 Author: Antoine Lambert <antoine.lambert@inria.fr> Date: Tue Mar 2 16:27:03 2021 +0100 tests: Drop hypothesis < 6 requirement Ensure tests can be executed using hypothesis >= 6 by suppressing the function_scoped_fixture health check on test that uses a function scope fixture in combination with @given that does not need to be reset between individual hypothesis examples.
Link to build: https://jenkins.softwareheritage.org/job/DCORE/job/tests-on-diff/199/
See console output for more information: https://jenkins.softwareheritage.org/job/DCORE/job/tests-on-diff/199/console
Build is green
Patch application report for D5182 (id=18556)
Rebasing onto 576b104799...
Current branch diff-target is up to date.
Changes applied before test
commit 76360cc7614f056fc789becf67b138ad7b12bf5f Author: Antoine Lambert <antoine.lambert@inria.fr> Date: Tue Mar 2 16:27:03 2021 +0100 tests: Drop hypothesis < 6 requirement Ensure tests can be executed using hypothesis >= 6 by suppressing the function_scoped_fixture health check on test that uses a function scope fixture in combination with @given that does not need to be reset between individual hypothesis examples.
See https://jenkins.softwareheritage.org/job/DCORE/job/tests-on-diff/200/ for more details.