pydev对nose2的支持

pydev对nose2的支持,pydev,nose,Pydev,Nose,我已经用PyDev成功地运行了鼻子测试,并想尝试一下鼻子2 所以我安装了它 pip install nose2 将示例代码从复制/粘贴到名为“test_script_with_nose2”的新模块中: from nose2.compat import unittest from nose2.tools import params def tests_can_be_functions(): assert True def tests_can_be_generators():

我已经用PyDev成功地运行了鼻子测试,并想尝试一下鼻子2

所以我安装了它

pip install nose2
将示例代码从复制/粘贴到名为“test_script_with_nose2”的新模块中:

from nose2.compat import unittest
from nose2.tools import params

def tests_can_be_functions():
    assert True

def tests_can_be_generators():
    def check(val):
        assert val == val, "Identity failure!"
    for i in range(1, 4):
        yield check, i

@params(1, 2, 3)
def tests_can_take_parameters(p):
    assert p < 4, "How'd that get here?"

class TestsCanBeUnittestTestCases(unittest.TestCase):
    def setUp(self):
        self.x = 1
    def test_one(self):
        self.assertEqual(self.x, 1)

class TestsCanBePlainClasses(object):
    def setUp(self):
        self.me_too = 1
    def test(self):
        assert self.me_too == 1, "Not me too?"

我已经选择nose作为pydev中的单元测试运行程序,但可能它需要一个新的nose 2运行程序?如果是这样,有人知道怎么做吗?还是我遗漏了一些琐碎的东西?

这个未解决的答案推迟了几年,但我想提供这些信息

您提供的错误中的这一行表示正在使用nose而不是nose2,因为nose2是一个单独的包,可通过pip安装:

File "/usr/local/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
我还尝试在pydev中使用
nose2
,从
nose
升级。我卸载了
nose
并安装了
nose2
,然后尝试运行您提供的测试代码,但在导入
nose2
时失败,而不是您提供的错误

ImportError: No module named nose2.compat
然后,我尝试了一些已经进行过的单元测试,但得到了以下消息:

Warning: Could not import the test runner: --nose-params. Running with the default pydev unittest runner instead.
因此,截至目前为止,nose2在pydev中似乎仍然不受支持

Warning: Could not import the test runner: --nose-params. Running with the default pydev unittest runner instead.