python - 无法使用 Nose 测试运行测试

标签 python django nosetests

我正在尝试使用nosetests来运行我的项目中的所有测试用例。

我 cd 到我的项目目录:

cd projects/myproject

然后我这样做:

nosetests

哪些输出:

----------------------------------------------------------------------
Ran 0 tests in 0.001s

OK

在projects/myproject 中,我有一个名为Encode 的包,在该包中我有带有测试的Test 目录:

Encode/
    __init__.py
    Video.py
    Ffmpeg.py
    Test/
        VideoTest.py
        FfmpegTest.py

为什么nosetests 没有检测到我的单元测试?我的所有单元测试类都扩展了unittest.TestCase。

最佳答案

来自nose docs :

Any function or class that matches the configured testMatch regular expression ((?:^|[\b_\.-])[Tt]est) by default – that is, has test or Test at a word boundary or following a - or _) and lives in a module that also matches that expression will be run as a test.

找不到您的测试,因为您的文件名与模式不匹配。例如,将它们更改为 Video_Test.py 或 Test_Video.py。顺便说一句:他们有这样的驼峰命名也很奇怪,但这不会阻止他们工作。

关于python - 无法使用 Nose 测试运行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11263343/

相关文章:

python - 使用 mechanize 和 beautifulsoup 进行网页抓取 - 无法写入输出文件

Python多处理设计

jquery - 将 jquery 与 django Rest api 一起放置

python - 在 Python 包上使用 Nose & NoseXUnit

python - Python 3 中的 Nose 提示但不是 2

python - 如何使用 keras.prediction 将测试数据与预测数据对齐?

python - 在 Matplotlib/seaborn 中绘制 Pandas 系列

python - Django JavaScript 翻译不起作用

python - 逆向django中的Ajax模块构建通知系统

python - 使用 eq_ 和 Nose 测试,有没有办法知道两个字符串的哪一行和哪一行不同?