这可能真的很愚蠢,但我无法让它发挥作用......
我想在such
中使用nose2
DLS和Linux中的python 2.7。
我正在从文档http://nose2.readthedocs.org/en/latest/such_dsl.html中尝试示例的开头(请参阅下面的代码),但无论我是如何从命令行启动测试的,它都不会运行测试。
我的文件名为test_something.py,它是目录中唯一的文件。
我尝试使用>> nose2
和>> nose2 --plugin nose2.plugins.layers
从命令行运行,但我总是得到Ran 0 tests in 0.000s
。使用>> nose2 --plugin layers
,我得到ImportError: No module named layers
。
我应该如何从命令行运行此测试? 谢谢!
以下代码:
import unittest
from nose2.tools import such
with such.A("system with complex setup") as it:
@it.has_setup
def setup():
print "Setup"
it.things = [1]
@it.has_teardown
def teardown():
print "Teardown"
it.things = []
@it.should("do something")
def test():
print "Test"
assert it.things
it.assertEqual(len(it.things), 1)
答案 0 :(得分:0)
DOH!
我忘了在文件的末尾添加it.createTests(globals())
!