Replies: 1 comment
-
def pytest_generate_tests(metafunc: pytest.Metafunc) -> None:
if "fixture_str" in metafunc.fixturenames:
values = [str(uuid.uuid4())]
metafunc.parametrize("fixture_str", values, indirect=True, ids=["str"]) Even fixtures parameterized like these fail! even though it's a list of strings |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How do I pass objects in
pytest_generate_tests
>metafunc.parametrize
and retain class or session scope. The discussion has been open for quite some time, and I don't have a clear idea on how to fix it. (#5738, #12931).The code I used to generate is attached below. When I pass a string list in
metafunc.parametrize
>arg values
, the scope is maintained, while when I pass a list of objects, the scope is not maintained. For the code below, I get the following output.As you see first and second line has different UUIDs (this was the list of objects) while the fixture has class scope, but 3 and 4 have the same UUID(this was the list of strings).
my_class.py
conftest.py
sample.py
execute test as
Beta Was this translation helpful? Give feedback.
All reactions