Skip to content
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

Alternatives created by fixture unions should be easily visible in test ids #41

Closed
smarie opened this issue Jun 14, 2019 · 0 comments
Closed
Labels
enhancement New feature or request

Comments

@smarie
Copy link
Owner

smarie commented Jun 14, 2019

from pytest_cases import param_fixture, fixture_union

a = param_fixture("a", [1, 2])
b = param_fixture("b", [3, 4])

c = fixture_union('c', ['a', 'b'])

def test_the_ids(c):
    pass

Currently leads to the following ids:

test_fixture_union_ids.py::test_the_ids[a-1] 
test_fixture_union_ids.py::test_the_ids[a-2] 
test_fixture_union_ids.py::test_the_ids[b-3] 
test_fixture_union_ids.py::test_the_ids[b-4]

It will maybe not be very understandable in more complex cases. Besides as of today if one tries to set the ids manually he will get an error ValueError: ids cannot be set on a union fixture.

I propose to (1) allow ids to be set on union fixtures, and (2) propose an additional "idstyle" argument with three options:

  • idstyle=None: a, b (current implementation): there is no way to distinguish this from other parameters
  • idstyle='compact': Ua, Ub
  • idstyle='explicit': c_is_a, c_is_b. This would become the default.

Note that this new parameter should be available in pytest_parametrize_plus too.

@smarie smarie added the enhancement New feature or request label Jun 14, 2019
@smarie smarie closed this as completed in 9f12605 Jun 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant