如何在buffer = True的PyCharm中运行python unittest

时间:2015-03-19 10:06:34

标签: python unit-testing pycharm

建立在How to assert output with nosetest/unittest in python?之上我想在Pyharm中解决这个问题。但是,pycharm不会运行:

$ python -m tests.test_mymodule --buffer

相反,它确实:

$ /usr/bin/python2.7 /opt/helpers/pycharm/utrunner.py \
  /home/oz123/PycharmProjects/account/tests/test_mymodule.py true

所以,我用它来运行:

$ /usr/bin/python2.7 /opt/helpers/pycharm/utrunner.py \
  /home/oz123/PycharmProjects/account/tests/test_mymodule.py --buffer true

它崩溃了:

##teamcity[testFinished duration='72' name='test_1_list_files']
Traceback (most recent call last):
  File "/opt/helpers/pycharm/utrunner.py", line 151, in <module>
    TeamcityTestRunner().run(all, **options)
  File "/opt/helpers/pycharm/tcunittest.py", line 249, in run
    test(result)
  File "/usr/lib/python2.7/unittest/suite.py", line 70, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib/python2.7/unittest/suite.py", line 108, in run
    test(result)
  File "/usr/lib/python2.7/unittest/suite.py", line 70, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib/python2.7/unittest/suite.py", line 108, in run
    test(result)
  File "/usr/lib/python2.7/unittest/case.py", line 396, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib/python2.7/unittest/case.py", line 356, in run
    result.addError(self, sys.exc_info())
  File "/opt/helpers/pycharm/tcunittest.py", line 108, in addError
    TestResult.addError(self, test, err)
  File "/usr/lib/python2.7/unittest/result.py", line 19, in inner
    return method(self, *args, **kw)
  File "/usr/lib/python2.7/unittest/result.py", line 116, in addError
    self.errors.append((test, self._exc_info_to_string(err, test)))
  File "/usr/lib/python2.7/unittest/result.py", line 167, in _exc_info_to_string
    output = sys.stdout.getvalue()
AttributeError: 'file' object has no attribute 'getvalue'

有人知道pycharm存储输出的位置吗?我该如何访问它?

0 个答案:

没有答案