python - 如何在 Nose2 中运行特定测试

标签 python nosetests unittest2 nose2

在以前版本的 Nose 测试框架中,有几种方法可以只指定所有测试的一个子集:

nosetests test.module
nosetests another.test:TestCase.test_method
nosetests a.test:TestCase
nosetests /path/to/test/file.py:test_function

http://nose.readthedocs.org/en/latest/usage.html#selecting-tests

但是,我在 Nose2 中找不到任何关于类似测试选择的信息。有一个 mention在关于不同测试发现的文档中,但这似乎并不相关。

有没有办法在 nose2 或(更一般地)unittest2 中选择特定的测试或测试用例?

最佳答案

我在开发/测试中有一些测试,例如:

dev/tests/test_file.py

我可以用:

nose2 -s dev tests.test_file

此外,我能够在测试用例中运行特定的测试方法,如下所示:

nose2 -s dev tests.test_file.TestCase.test_method

这是否实现了您想要的?

关于python - 如何在 Nose2 中运行特定测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17890087/

相关文章:

在 Mac OS X 虚拟环境中安装 Python,其中包括我可以包含到 Xcode 中的框架?

python - 在 Python 中使用列表中的名称在循环中创建新变量

Python nosetest 不起作用,但直接运行它可以使用 matplotlib 的 @image_comparison

python - 配置 python-coveralls

Python Unittest2 - 避免在 discover() 中包含 TestCase

python - OpenCV 在 Linux 上的 python 与 anaconda 无法正常工作。收到未实现 cv2.imshow() 的错误

Python 正则表达式 * 仅匹配字符串开头的出现次数

python - 使用Python在Hudson中配置 "execute shell"脚本

python - 是否可以使用 unit2 运行 doctests

python - 如何在python setup.py test中使用unittest2