Skip to content

Fixed lazy value resolution issue when multiple consecutive lazy values are present in a @parametrize containing a fixture_ref #275

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

Merged
merged 3 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### 3.6.13 - bugfix

- Fixed issue where a lazy value (for example a case function) was not resolved before being injected in a parametrized function, and was therefore appearing as a `_LazyValueCaseParamValue `. Fixed [#274](https://github.com/smarie/python-pytest-cases/issues/274)

### 3.6.12 - type hint fix + enhanced compatibility with pytest plugins

- Improved compatibility with other `pytest` plugins, in particular `pytest-repeat`, by supporting removal from fixture closure tree. Fixed [#269](https://github.com/smarie/python-pytest-cases/issues/269).
Expand Down
2 changes: 1 addition & 1 deletion src/pytest_cases/fixture_core2.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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]',
]