Merge pull request #9144 from bluetech/py36_order_by_definition

py36+ tests are definition ordered [v2]
This commit is contained in:
Ran Benita
2021-10-01 16:17:37 +03:00
committed by GitHub
parent d8831c64eb
commit 5fc3e35afb
3 changed files with 46 additions and 9 deletions

View File

@@ -770,6 +770,36 @@ class TestSorting:
assert len(colitems) == 2
assert [item.name for item in colitems] == ["test_b", "test_a"]
def test_ordered_by_definition_order(self, pytester: Pytester) -> None:
pytester.makepyfile(
"""\
class Test1:
def test_foo(): pass
def test_bar(): pass
class Test2:
def test_foo(): pass
test_bar = Test1.test_bar
class Test3(Test2):
def test_baz(): pass
"""
)
result = pytester.runpytest("--collect-only")
result.stdout.fnmatch_lines(
[
"*Class Test1*",
"*Function test_foo*",
"*Function test_bar*",
"*Class Test2*",
# previously the order was flipped due to Test1.test_bar reference
"*Function test_foo*",
"*Function test_bar*",
"*Class Test3*",
"*Function test_foo*",
"*Function test_bar*",
"*Function test_baz*",
]
)
class TestConftestCustomization:
def test_pytest_pycollect_module(self, pytester: Pytester) -> None: