python - 执行 pytest 测试用例时如何在命令提示符中使用通配符

标签 python pycharm pytest

我在 Pycharm 中有以下项目结构。

项目文件夹: PythonTutorial

包: pytestpackage

Python 文件: test_conftest_demo1.py、test_conftest_demo2.py

我正在尝试使用以下命令在命令提示符下使用 pytest 运行上述 2 个具有几乎相似名称的 python 文件。但我面临以下问题。请帮助我。

注意:我使用的是 Windows 10 操作系统。

使用的命令: py.test -s -v test_conftest_demo*.py

enter image description here

最佳答案

使用-k选项指定子字符串匹配。

$ pytest -s -v -k "test_conftest_demo"

关于python - 执行 pytest 测试用例时如何在命令提示符中使用通配符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56484018/

相关文章:

python - 有没有办法在不同模块之间传递Python中的类对象并保留命名空间?

python - Pytest 没有在终端中提供正确的输出

python - 多处理时全局变量的名称错误,仅在子目录中

python - numpy.exponential 行为略有不同

python - 如何让 pyCharm 停止隐藏(展开)我的 Python 导入?

python - Pytest HTML 报告 : how to get the name of the report file?

pytest - 如何使用 tox+pytest 启用 DeprecationWarning 和 PendingDeprecationWarning 测试

python - pygame音频代码不起作用

c# - 如何使用python .Net与ZeroMQ或其他将Python包公开给C#

python - 模块未找到错误: Python files seem to behave differentely inside and outside of Pycharm