Skip to content

Pytest fails for find tests when @parametrize args are sets with multiple values #355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
TheCaffinatedDeveloper opened this issue Oct 30, 2024 · 1 comment

Comments

@TheCaffinatedDeveloper
Copy link

TheCaffinatedDeveloper commented Oct 30, 2024

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 :)

@TheCaffinatedDeveloper TheCaffinatedDeveloper changed the title Pytest fails for find tests when @parametrize args are iterables Pytest fails for find tests when @parametrize args are sets with multiple values Oct 30, 2024
@smarie
Copy link
Owner

smarie commented May 6, 2025

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants