python-pytest-cases
python-pytest-cases copied to clipboard
Pytest fails for find tests when @parametrize args are sets with multiple values
I believe this has something to do with idgen at some point but when you do the following
class SomeCases:
@parametrize(arg1=[{"set_value_1", "set_value_2"}, {}, {"set_value_1"})
def case_some_case(arg1: set[str]) -> set[str]:
return arg1
@parametrize_with_cases("arg", cases=SomeCases)
def test_some_cases(arg: set[str]) -> None:
assert arg is not None
On the tests that use multiple values within the set, pytest is unable to locate them at run time even though it finds them during collection it seems.
Note: I actually was able to reproduce this within pytest itself when replacing their ids=with lambda x: f"arg1 {str(x)}" so perhaps not a pytest_cases specific issue? Could be another enhancement though :)
Thanks @TheCaffinatedDeveloper for reporting this issue ! And sorry for the delay in responding.
I was not able to reproduce the issue based on the provided code. I had to add the imports and the "self" argument, as well as the missing bracket though :
from pytest_cases import parametrize_with_cases, parametrize
class SomeCases:
@parametrize(arg1=[{"set_value_1", "set_value_2"}, {}, {"set_value_1"}])
def case_some_case(self, arg1: set[str]) -> set[str]:
return arg1
@parametrize_with_cases("arg", cases=SomeCases)
def test_some_cases(arg: set[str]) -> None:
assert arg is not None
I am running this on the latest version of pytest cases and pytest 8.0.2 on python 3.12. All tests pass correctly.
Which version are you using ? What exception do you see ?