JetBrains / teamcity-messages

Python Unit Test Reporting to TeamCity
https://pypi.python.org/pypi/teamcity-messages
Apache License 2.0
137 stars 81 forks source link

Wrong number of tests reported for pytest launched with ``--last-failed`` #227

Open throwable-one opened 4 years ago

throwable-one commented 4 years ago
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.

Affects: https://youtrack.jetbrains.com/issue/PY-41270