我试图使用setup.cfg中的norecursedirs
选项来告诉py.test不要从某些目录收集测试,但似乎它确实忽略它。如何让py.test跳过某些目录?
[tool:pytest]
norecursedirs=lib/third
当我运行py.test
我看到它是如何从内部lib/third
得到测试!
我试图使用setup.cfg中的norecursedirs
选项来告诉py.test不要从某些目录收集测试,但似乎它确实忽略它。如何让py.test跳过某些目录?
[tool:pytest]
norecursedirs=lib/third
当我运行py.test
我看到它是如何从内部lib/third
得到测试!
我解开了谜团:如果pytest部分在可能的配置文件(pytest.ini
,tox.ini
和setup.cfg
),pytest不会寻找任何其他人发现所以一定要在一个单一的定义py.test选项文件。我建议使用setup.cfg
。
norecursedirs
应该工作。检查你是否有pytest.ini或其他setup.cfg文件。你是怎么调用py.test
?
我的'setup.cfg'里面有正确的'[pytest]'和norecorsedirs,但它似乎被忽略,而是会查找所有文件。 – sorin
您可以使用
py.test -k 'not third'
排除所有的 '第三' 目录的内容。
py.test --ignore=somedir
工作对我来说
如果您正在使用setup.cfg,你必须使用[tool:pytest]
按照http://doc.pytest.org/en/latest/example/pythoncollection.html
#内容pytest.ini
#也可以在TOX定义。 ini或setup.cfg文件,但在setup.cfg文件中的#名称应该是“tool:pytest”节
#
似乎我有'py.test'和'pytest'两个人都在进行测试并且是不同的野兽。奇怪,但'pytest'是一个失败的因为它不加载'[pytest]'的排除。 – sorin
'pytest'来自logilab。你想'py.test'。 – ecatmur
也试着做'nosecuredirs = lib/third/*' – intelis