繁体   English   中英

使用此类DSL的鼻子2找不到测试

[英]nose2 with such DSL does not find tests

这可能真的很愚蠢,但是我无法使其正常工作...我想在nose2中将such 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获得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)

DOH! 我忘了在文件末尾添加它it.createTests(globals())

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM