File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -82,3 +82,36 @@ def test_e(self):
82
82
*::TestClassNamed::test_d PASSED
83
83
*::TestClassNamed::test_e SKIPPED
84
84
""" )
85
+
86
+
87
+ @pytest .mark .xfail (reason = "Issue #6" )
88
+ def test_class_default_name (ctestdir ):
89
+ """For methods of test classes, the default name is the method name.
90
+ This may cause conflicts if there is a function having the same
91
+ name outside the class. Note how the method test_a() of class
92
+ TestClass shadows the failure of function test_a().
93
+ """
94
+ ctestdir .makepyfile ("""
95
+ import pytest
96
+
97
+ @pytest.mark.dependency()
98
+ def test_a():
99
+ assert False
100
+
101
+ class TestClass(object):
102
+
103
+ @pytest.mark.dependency()
104
+ def test_a(self):
105
+ pass
106
+
107
+ @pytest.mark.dependency(depends=["test_a"])
108
+ def test_b():
109
+ pass
110
+ """ )
111
+ result = ctestdir .runpytest ("--verbose" )
112
+ result .assert_outcomes (passed = 1 , skipped = 1 , failed = 1 )
113
+ result .stdout .fnmatch_lines ("""
114
+ *::test_a FAILED
115
+ *::TestClass::test_a PASSED
116
+ *::test_b SKIPPED
117
+ """ )
You can’t perform that action at this time.
0 commit comments