Skip to content

Commit

Permalink
Fixed issue where a lazy value (for example a case function) was not …
Browse files Browse the repository at this point in the history
…resolved before being injected in a parametrized function, and was therefore appearing as a `_LazyValueCaseParamValue `. Fixed #274
  • Loading branch information
Sylvain MARIE committed May 20, 2022
1 parent d3cf756 commit 57c1659
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pytest_cases/fixture_core2.py
Expand Up @@ -119,7 +119,7 @@ def __param_fixture(request):
# create the fixture - set its name so that the optional hook can read it easily
@with_signature("%s(request)" % argname)
def __param_fixture(request):
return request.param
return get_lazy_args(request.param, request)

if debug:
print("Creating parametrized fixture %r returning %r" % (argname, argvalues))
Expand Down
33 changes: 33 additions & 0 deletions tests/cases/issues/test_issue_274.py
@@ -0,0 +1,33 @@
import pytest
from pytest_cases import fixture, parametrize_with_cases


class DataCases:
def data_dummy(self):
return 1

def data_dummy2(self):
return 1

@pytest.mark.parametrize("a", [False])
def data_dummy3(self, a):
return 1


@fixture
@parametrize_with_cases("dset", cases=DataCases, prefix="data_", debug=True)
def dataset(dset):
assert dset == 1
yield dset


def test_foo(dataset):
assert dataset == 1


def test_synthesis(module_results_dct):
assert list(module_results_dct) == [
'test_foo[dummy]',
'test_foo[dummy2]',
'test_foo[dummy3-False]',
]

0 comments on commit 57c1659

Please sign in to comment.