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

前端 未结 3 1460
栀梦
栀梦 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:40

    I really suggest you to rename the directory to something not called "distutils". Why ? Because you are overriding an existing module. When "import distutils" or "from distutils import *" appear in the script (from another import or your own python file), it will prefer your directory instead the system one. If the module distutils have been already loaded before, your distutils will not be loaded, because the symbol already exists in global().

    It would be really simpler to rename that directory (like tests) instead of trying to fight with py.text / python internals.

提交回复
热议问题