Skip to content

Commit 4f5c466

Browse files
smarieSylvain MARIE
and
Sylvain MARIE
authored
Fixed lazy value resolution issue when multiple consecutive lazy values are present in a @parametrize containing a fixture_ref (#275)
* 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 * 3.6.13 changelog Co-authored-by: Sylvain MARIE <[email protected]>
1 parent 0ef1a0e commit 4f5c466

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

docs/changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
### 3.6.13 - bugfix
4+
5+
- 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)
6+
37
### 3.6.12 - type hint fix + enhanced compatibility with pytest plugins
48

59
- 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).

src/pytest_cases/fixture_core2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def __param_fixture(request):
119119
# create the fixture - set its name so that the optional hook can read it easily
120120
@with_signature("%s(request)" % argname)
121121
def __param_fixture(request):
122-
return request.param
122+
return get_lazy_args(request.param, request)
123123

124124
if debug:
125125
print("Creating parametrized fixture %r returning %r" % (argname, argvalues))

tests/cases/issues/test_issue_274.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import pytest
2+
from pytest_cases import fixture, parametrize_with_cases
3+
4+
5+
class DataCases:
6+
def data_dummy(self):
7+
return 1
8+
9+
def data_dummy2(self):
10+
return 1
11+
12+
@pytest.mark.parametrize("a", [False])
13+
def data_dummy3(self, a):
14+
return 1
15+
16+
17+
@fixture
18+
@parametrize_with_cases("dset", cases=DataCases, prefix="data_", debug=True)
19+
def dataset(dset):
20+
assert dset == 1
21+
yield dset
22+
23+
24+
def test_foo(dataset):
25+
assert dataset == 1
26+
27+
28+
def test_synthesis(module_results_dct):
29+
assert list(module_results_dct) == [
30+
'test_foo[dummy]',
31+
'test_foo[dummy2]',
32+
'test_foo[dummy3-False]',
33+
]

0 commit comments

Comments
 (0)