`py.test` and `__init__.py` files

前端 未结 3 1475
栀梦
栀梦 2020-12-20 20:13

I thought py.test is \"standalone\" in a sense that it treats test_*.py files \"as it is\", and only imports modules specified in these files, with

3条回答
  •  忘掉有多难
    2020-12-20 20:31

    Looks like py.test is using py._path.pyimport to open your file. If there is a __init__.py file in the directory, it treats your file as a module, otherwise it opens the file. Long story short, delete the __init__.py or put your tests in another directory outside your project code (<--- good idea).

    http://doc.pylib.org/en/latest/_modules/py/_path/local.html#LocalPath.pyimport

提交回复
热议问题