Skip to content

Commit 88995d5

Browse files
author
Sylvain MARIE
committed
Fixed ordering issue happening on linux targets when several @parametrize are used to decorate the same function. Fixes #180
1 parent 8e4fb1e commit 88995d5

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

pytest_cases/fixture_parametrize_plus.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,12 @@ def wrapped_test_func(*args, **kwargs): # noqa
10491049
# move_all_pytest_marks(test_func, wrapped_test_func)
10501050

10511051
# With this hack we will be ordered correctly by pytest https://github.com/pytest-dev/pytest/issues/4429
1052-
wrapped_test_func.place_as = test_func
1052+
try:
1053+
# propagate existing attribute if any
1054+
wrapped_test_func.place_as = test_func.place_as
1055+
except: # noqa
1056+
# position the test at the original function's position
1057+
wrapped_test_func.place_as = test_func
10531058

10541059
# return the new test function
10551060
return wrapped_test_func

pytest_cases/tests/pytest_extension/issues/test_issue_177.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ def test_stuff_multi(letters, order, no_auto, no_auto2, explicit_auto, explicit_
5151
assert letters.upper() == letters.lower().upper()
5252

5353

54-
def test_synthesis(module_results_dct):
55-
if has_pytest_param:
54+
def test_synthesis(module_results_dct):
5655
assert list(module_results_dct) == [
5756
'test_stuff[a-b-True-a]',
5857
'test_stuff[a-b-False-a]',
@@ -63,5 +62,3 @@ def test_synthesis(module_results_dct):
6362
'test_stuff_multi[c-b-no-a-yes]',
6463
'test_stuff_multi[ho-b-no-a-yes]'
6564
]
66-
else:
67-
assert list(module_results_dct) == []

0 commit comments

Comments
 (0)