Skip to content

Commit 63b7903

Browse files
author
Sylvain MARIE
committed
Added test and comments
1 parent 627cd25 commit 63b7903

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

pytest_cases/case_parametrizer_new.py

+1
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ def funcopy(f):
390390
else:
391391
if target_in_class:
392392
# case in module and target in class: create a static method
393+
# TODO this is actually never called because host is never the class. To check.
393394
case_fun = staticmethod(case_fun)
394395
else:
395396
# none in class: direct copy

pytest_cases/common_pytest.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,12 @@ def inject_host(apply_decorator):
714714
# return _apply_decorator_with_host_tracking
715715

716716
def apply(test_or_fixture_func):
717-
# approximate but far less complex to debug than above !
717+
# approximate: always returns the module and not the class :(
718+
#
719+
# indeed when this is called, the function exists (and its qualname mentions the host class) but the
720+
# host class is not yet created in the module, so it is not found by our `get_class_that_defined_method`
721+
#
722+
# but still ... this is far less complex to debug than the above attempt and it does not yet have side effects..
718723
container = get_function_host(test_or_fixture_func)
719724
return apply_decorator(test_or_fixture_func, container)
720725

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from pytest_cases import parametrize_with_cases, fixture
2+
3+
4+
class Cases:
5+
6+
def case_one(self, bird):
7+
return "one"
8+
9+
def case_two(self):
10+
return "two"
11+
12+
13+
@parametrize_with_cases("v", cases=Cases)
14+
def test_this_is_failing(v):
15+
assert v in ["one", "two"]
16+
17+
18+
@fixture
19+
def bird():
20+
return "one_proud_bird"

0 commit comments

Comments
 (0)