Programming

nosetests가 내 인쇄 명세서의 출력을 캡처하고 있습니다.

procodes 2020. 6. 20. 13:39
반응형

nosetests가 내 인쇄 명세서의 출력을 캡처하고 있습니다. 이것을 우회하는 방법?


입력 할 때

$ nosetests -v mytest.py

모든 테스트가 통과되면 모든 인쇄 출력이 캡처됩니다. 모든 것이 통과해도 인쇄 출력을보고 싶습니다.

그래서 내가하고있는 일은 어설 션 오류가 출력을 보도록 강제하는 것입니다.

class MyTest(TestCase):

    def setUp(self):
        self.debug = False

    def test_0(self):
        a = .... # construct an instance of something
        # ... some tests statements
        print a.dump()
        if self.debug:
            eq_(0,1)

그것은 해킹처럼 느껴지므로 더 좋은 방법이 있어야합니다. 제발 깨달아 줘


어느 한 쪽:

$ nosetests --nocapture mytest.py

또는:

$ NOSE_NOCAPTURE=1 nosetests mytests.py

( nose.cfg파일에 지정할 수도 있습니다 . 참조 nosetests --help)


사용하다

--nologcapture 

그것은 나를 위해 일했다


이것은 --nocapture 대신에 최근에 코에 추가되었습니다.

코 테스트 -s


http://travis-ci.org 와 통합하기 위해 이것을 .travis.yml에 넣었습니다 .

script:  "python setup.py nosetests -s"

어디 setup.py가 포함되어 있습니다 :

setup(
    ...
    tests_require=['nose>=1.0'],
    test_suite='nose.collector',
)

참고 : https://stackoverflow.com/questions/5975194/nosetests-is-capturing-the-output-of-my-print-statements-how-to-circumvent-this

반응형