我用一个新的virtualenv创建一个简单的新项目。requirements.txt
只有pytest
,就这样。在
.
├── requirements.txt
└── tests
├── __init__.py
└── sample_tests.py
sample_tests.py
:
如果我使用python测试文件名运行pytest,它可以正常工作:
vex --path ~/.virtualenvs/pytestdemo pytest tests/sample_tests.py
但是,以下调用都不起作用。它们都无法看到测试和输出collected 0 items
和{
vex --path ~/.virtualenvs/pytestdemo pytest tests
vex --path ~/.virtualenvs/pytestdemo pytest tests/
vex --path ~/.virtualenvs/pytestdemo pytest
vex --path ~/.virtualenvs/pytestdemo python -m pytest tests
vex --path ~/.virtualenvs/pytestdemo python -m pytest tests/
vex --path ~/.virtualenvs/pytestdemo python -m pytest
在这个简单的场景中,我只有一个测试文件和一个测试,但在我的实际应用程序中,我有许多测试,我希望通过一个简单的调用来运行所有这些测试。我已经将我的场景缩小到这个超级简单的独立示例中,我想让非常基本的测试调用工作起来。在
我把文档和入门指南都翻了一遍。我尝试过使用(而不是使用)自定义pytest.ini
。显然,我尝试了通过pytest
和{
默认情况下,}(来自docs)的文件中发现测试。这就是为什么当您直接将文件名作为参数传递时,它会在文件中查找测试:
pytest
只在名为test_*.py
或{但在其他的调用中找不到它们。所以,你的选择是:
相关问题 更多 >
编程相关推荐