Merge pull request #9144 from bluetech/py36_order_by_definition
py36+ tests are definition ordered [v2]
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user