Repository navigation
Replies: 1 comment
|
🤖 Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it. Fixtures are not available at collection time, so they cannot feed # conftest.py
import json
def pytest_generate_tests(metafunc):
if "case" in metafunc.fixturenames:
path = metafunc.config.getoption("--tests")
with open(path) as f:
metafunc.parametrize("case", json.load(f)) |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
In a py.test code I can specify some file that can be used for some tests. So in the
conftest.pyI defineso I have a fixture which represents a filename.
Now in the test itself I want to use this filename to parametrize a test as follows:
but that does not work as the fixture
testfiledoes not seem to be defined/accessible in "front of" a test method. And for extremly complicated reasons I have to use parameterized.So any idea on how to fix this issue, so I can create parameterised tests in py.test with test reads from a dynamically defined filename?
All reactions