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

Support for lazy_value in parametrize_plus #92

Closed
smarie opened this issue Jun 2, 2020 · 0 comments · Fixed by #95
Closed

Support for lazy_value in parametrize_plus #92

smarie opened this issue Jun 2, 2020 · 0 comments · Fixed by #95
Labels
enhancement New feature or request

Comments

@smarie
Copy link
Owner

smarie commented Jun 2, 2020

A missing part for V2 (convergence between case functions and pytest mechanisms, see #90 ) is the capability to not create a fixture for every case function. Indeed this is not necessarily needed: for example when the case function has no parametrization at all and does not depend on any fixture.

Also we might argue that when a case function only has parametrization (case generator) but no fixture dependency (no parametrize plus!) this can also be done without creating a fixture.

The proposed mechanism is

from pytest_cases import parametrize_plus

def valtuple():
    return 1, 2

def val():
    return 2

@parametrize_plus("a,b", [value_ref(valtuple),
                          (1, value_ref(val))])
def test_foo(a, b):
    assert (a, b) == (1, 2)

In terms of implementation, the list passed to parametrize_plus would be a custom list with a hook on __getitem__.

@smarie smarie added the enhancement New feature or request label Jun 2, 2020
smarie pushed a commit that referenced this issue Jun 11, 2020
@smarie smarie changed the title Support for value_ref in parametrize_plus Support for lazy_value in parametrize_plus Jun 11, 2020
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

Successfully merging a pull request may close this issue.

1 participant