Test discovery failure when tests in different directories are called the same

前端 未结 4 410
旧巷少年郎
旧巷少年郎 2020-12-13 12:06

Using py.test, two tests called the same in different directory causes py.test to fail. Why is that? How can I change this without renaming all the tests?

To duplica

4条回答
  •  感动是毒
    2020-12-13 12:25

    I had the same error, but the solution had nothing to do with the init files nor the name on the test files. I had different python versions on my macbook and on my Docker container. I launched the tests once in the bash from the macbook at the root of the project, instead of the bash of the container.

    The solution was to remove the wrongly created files by running (from the bash of the container):

    find -name '*.pyc' -delete
    find -name __pycache__ -delete
    

    Then launch the test again (still from the bash of the container) and everything worked just fine:

    py.test
    

提交回复
热议问题