2012-12-21 2 views
3

저는 PyDev로 코 테스트를 성공적으로 수행하여 nose2를 사용해보고 싶습니다.pydev가 nose2를 지원합니다.

그래서 나는/

pip install nose2 

사본을 설치 'test_script_with_nose2'라는 새로운 모듈에 http://nose2.info/에서 샘플 코드를 붙여 :

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?" 

하지만이 오류가

====================================================================== 
ERROR: test_script_with_nose2.tests_can_take_parameters 
---------------------------------------------------------------------- 
Traceback (most recent call last): 
    File "/usr/local/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest 
    self.test(*self.arg) 
TypeError: tests_can_take_parameters() takes exactly 1 argument (0 given) 

---------------------------------------------------------------------- 
Ran 7 tests in 0.014s 

FAILED (errors=1) 

pydev에서 단위 테스트 러너로 선정 된 코가 있지만, 아마도 그렇지 않습니다. nose2에 대한 새로운 주자? 그렇다면 누구나이 작업을 수행 할 수 있습니다. 아니면 내가 여기에 사소한 것을 놓치고 있니?

답변

0

이 미해결 된 답변은 2 년 지연되었지만이 정보를 제공해 드리고자합니다. 나는 또한 PyDev의에서 nose2을 사용하려고

File "/usr/local/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest 

nose에서 업그레이드 : nose2이 핍을 통해 별도의 패키지 설치 이후

제공된 오류이 라인은 코 대신 nose2의 사용을 나타냅니다 . 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에서 아직 지원되지 않는 것 같다.

관련 문제