Skip to content

False positives using when using pytest-xdist -f (--looponfail) #85

@y2kbugger

Description

@y2kbugger

When doing TDD, after the first mypy error, the plugin start emitting errors on collection.

It will continue normally until you hit an actual mypy fail, then in the follow round (after mypy error is fixed) this warning is emitted forever until pytest is killed and restarted.

Steps to Reproduce (assumes python 3.8 and pipenv available):

  1. mkdir ~/tmp20200412
  2. cd ~/tmp20200412
  3. git clone git@bitbucket.org:y2kbugger/test_driven_development_by_example_tdd_follow_along.git
  4. cd ./test*
  5. git checkout b0a2f56
  6. replicate versions exactly from Pipfile.lock pipenv sync
  7. put venv on PATH pipenv shell
  8. run pytest pytest --mypy -f money.py test_money.py

In another terminal:

  1. cd ~/tmp20200412/test*
  2. cause mypy error echo 'lol: str = 2' >> money.py
  3. undo mypy error git checkout b0a2f56 -- .
###################################### waiting for changes #######################################
### Watching:   /home/y2k/devel/test_driven_development_by_example_tdd_follow_along
# MODIFIED /home/y2k/devel/test_driven_development_by_example_tdd_follow_along/money.py
============================= test session starts ==============================
platform linux -- Python 3.8.2, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: /home/y2k/devel/test_driven_development_by_example_tdd_follow_along
plugins: forked-1.1.3, mypy-0.6.1, xdist-1.31.0, flake8-1.0.4
collected 0 items / 1 error
collected 0 items / 1 error

==================================== ERRORS ====================================
________________________ ERROR collecting test session _________________________
../../.local/share/virtualenvs/test_driven_development_by_example_tdd_fol-TPMT2dI5/lib/python3.8/site-packages/_pytest/runner.py:244: in from_call
    result = func()
../../.local/share/virtualenvs/test_driven_development_by_example_tdd_fol-TPMT2dI5/lib/python3.8/site-packages/_pytest/runner.py:264: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
../../.local/share/virtualenvs/test_driven_development_by_example_tdd_fol-TPMT2dI5/lib/python3.8/site-packages/_pytest/main.py:498: in collect
    yield from self._collect(fspath, parts)
../../.local/share/virtualenvs/test_driven_development_by_example_tdd_fol-TPMT2dI5/lib/python3.8/site-packages/_pytest/main.py:537: in _collect
    assert not names, "invalid arg {!r}".format((argpath, names))
E   AssertionError: invalid arg (local('/home/y2k/devel/test_driven_development_by_example_tdd_follow_along'), ['mypy'])
=========================== short test summary info ============================
ERROR  - AssertionError: invalid arg (local('/home/y2k/devel/test_driven_deve...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.22s ===============================
######################################### LOOPONFAILING ##########################################
money.py::mypy
test_money.py::test_multiplication
test_money.py::test_franc_multiplication
test_money.py::test_equality
test_money.py::test_currency
::mypy
###################################### waiting for changes #######################################
### Watching:   /home/y2k/devel/test_driven_development_by_example_tdd_follow_along

Note I kill with keyboard interrupt here:

^C

Then everything goes fine again:

(test_driven_development_by_example_tdd_follow_along) [y2k@15r test_driven_development_by_example_tdd_follow_along]
$ pytest --mypy -f money.py test_money.py 
============================= test session starts ==============================
platform linux -- Python 3.8.2, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: /home/y2k/devel/test_driven_development_by_example_tdd_follow_along
plugins: forked-1.1.3, mypy-0.6.1, xdist-1.31.0, flake8-1.0.4
collected 7 items
collected 7 items

money.py .                                                               [ 12%]
test_money.py ......                                                     [ 87%]
. .                                                                      [100%]. [100%]
===================================== mypy =====================================

Success: no issues found in 2 source files
============================== 9 passed in 0.34s ===============================
###################################### waiting for changes #######################################
### Watching:   /home/y2k/devel/test_driven_development_by_example_tdd_follow_along

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions