Skip to content

Commit f8db27f

Browse files
authored
Merge pull request #172 from plammens/tests/improve-test-nested
tests: Improve test_nested
2 parents ba40ea8 + da86715 commit f8db27f

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

pytest_cases/tests/cases/doc/test_nested.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,33 @@ class SubFooCases:
99
def case_2(self):
1010
return 2
1111

12-
def case_3(self):
12+
class SubSubFooCases:
13+
def case_3(self):
14+
return 3
15+
16+
def case_3(self): # duplicate name; on purpose
1317
return 3
1418

1519

1620
@parametrize_with_cases("x", FooCases)
1721
def test_foo(x):
18-
print(x)
22+
test_foo.received.append(x)
23+
24+
25+
test_foo.received = []
26+
27+
28+
@parametrize_with_cases("x", FooCases.SubFooCases)
29+
def test_subfoo(x):
30+
test_subfoo.received.append(x)
31+
32+
33+
test_subfoo.received = []
34+
35+
36+
def test_class_with_nested_uses_nested():
37+
assert test_foo.received == [1, 2, 3, 3]
38+
39+
40+
def test_direct_nested_class_reference_works():
41+
assert test_subfoo.received == [2, 3]

0 commit comments

Comments
 (0)