Skip to content

Commit 499ab53

Browse files
committed
Add a test with a dependency on a method of a test class in session scope.
1 parent 291c964 commit 499ab53

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

tests/test_03_scope.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,15 @@ def test_a():
5555
def test_b():
5656
assert False
5757
58-
@pytest.mark.dependency(depends=["test_a"], scope='module')
58+
@pytest.mark.dependency(depends=["test_a"])
5959
def test_c():
6060
pass
61+
62+
class TestClass(object):
63+
64+
@pytest.mark.dependency()
65+
def test_b(self):
66+
pass
6167
""", test_scope_session_02="""
6268
import pytest
6369
@@ -86,17 +92,26 @@ def test_f():
8692
)
8793
def test_g():
8894
pass
95+
96+
@pytest.mark.dependency(
97+
depends=["test_scope_session_01.py::TestClass::test_b"],
98+
scope='session'
99+
)
100+
def test_h():
101+
pass
89102
""")
90103
result = ctestdir.runpytest("--verbose")
91-
result.assert_outcomes(passed=4, skipped=1, failed=2)
104+
result.assert_outcomes(passed=6, skipped=1, failed=2)
92105
result.stdout.fnmatch_lines("""
93106
test_scope_session_01.py::test_a PASSED
94107
test_scope_session_01.py::test_b FAILED
95108
test_scope_session_01.py::test_c PASSED
109+
test_scope_session_01.py::TestClass::test_b PASSED
96110
test_scope_session_02.py::test_a FAILED
97111
test_scope_session_02.py::test_e PASSED
98112
test_scope_session_02.py::test_f SKIPPED
99113
test_scope_session_02.py::test_g PASSED
114+
test_scope_session_02.py::test_h PASSED
100115
""")
101116

102117
@pytest.mark.xfail(reason="package scope not yet implemented")

0 commit comments

Comments
 (0)