class TestPyTest:
def testOne(self):
print("I am test1")
assert 5 == 2*2
def testTwo(self):
assert True
def testFail(self):
print("I will fail")
sleep(1) # To check duration
assert False
Run this class. Then, run it with --last-failed.
Expected result: count=2.
Actual result: count=3.
Cause:
pytest deselects one test and reports 3 items for pytest_collection_modifyitems but reports 2 (correct!) number of items for pytest_collection_finish.
Since pytest_collection_finish exists for more than one year, we must use it instead.
Run this class. Then, run it with
--last-failed
. Expected result:count=2
. Actual result:count=3
.Cause: pytest deselects one test and reports 3 items for
pytest_collection_modifyitems
but reports 2 (correct!) number of items forpytest_collection_finish
.Since
pytest_collection_finish
exists for more than one year, we must use it instead.Affects: https://youtrack.jetbrains.com/issue/PY-41270