[英]Cannot run tests with nosetests
I am trying to use nosetests to run all test cases inside my project. 我正在尝试使用鼻子测试在项目中运行所有测试用例。
I cd to my project directory: 我进入我的项目目录:
cd projects/myproject
Then I do: 然后我做:
nosetests
Which outputs: 哪个输出:
----------------------------------------------------------------------
Ran 0 tests in 0.001s
OK
Inside projects/myproject I have a package called Encode and inside the package I have Test directory with tests: 在projects / myproject内部,我有一个名为Encode的软件包,在该软件包中我有带有测试的Test目录:
Encode/
__init__.py
Video.py
Ffmpeg.py
Test/
VideoTest.py
FfmpegTest.py
Why is nosetests not detecting my unit tests? 为什么鼻子测试不能检测到我的单元测试? All of my unit test classes extend unittest.TestCase.
我所有的单元测试类都扩展了unittest.TestCase。
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.
默认情况下,任何与已配置的testMatch正则表达式((?:^ | [\\ b _ \\ .-])[Tt] est)匹配的函数或类-即在单词边界处或在-或_之后具有test或Test ),并位于与该表达式匹配的模块中,该模块将作为测试运行。
Your tests aren't being found because your filenames don't match the pattern. 找不到您的测试,因为文件名与模式不匹配。 Change them to Video_Test.py, or Test_Video.py, for example.
例如,将它们更改为Video_Test.py或Test_Video.py。 BTW: It's also odd that they have camelCase names like that, but that won't stop them from working.
顺便说一句:他们有这样的骆驼名,这也很奇怪,但这不会阻止他们的工作。
nose
won't find your tests if they are buried in a subdirectory. 如果将它们埋在子目录中,
nose
将找不到您的测试。 You should be able to tell it where to look though. 您应该能够告诉它在哪里看。 Try
nosetests --where=Encode/Test
. 尝试
nosetests --where=Encode/Test
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.