Single assertion error creates excessive output in PyCharm test runner
Hello,
Is this normal or not? Using the simplest unittest file, generated by PyCharm, the output seems excessive (see below). exception within an exception, and a bunch of extra assertion failed errors following. Unittests is set as the default test runner. pycharm Community 2020.1. Using Python 3.8 in a virtual environment.
If I run this outside of PyCharm's test runner ('run test_unittest.py' instead of 'run unittests in test_unittest.py') it looks reasonable.
This feels like some configuration I have wrong, and I'm pretty new to PyCharm. Thanks for any input.
import unittest
class MyTestCase(unittest.TestCase):
def test_something(self):
self.assertEqual(True, False)
if __name__ == '__main__':
unittest.main()
Testing started at 8:46 AM ...
C:\Users\Bill\PycharmProjects\TestProj\venv\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2020.1.1\plugins\python-ce\helpers\pycharm\_jb_unittest_runner.py" --path C:/Users/Bill/PycharmProjects/TestProj/test_unittest.py
Launching unittests with arguments python -m unittest C:/Users/Bill/PycharmProjects/TestProj/test_unittest.py in C:\Users\Bill\PycharmProjects\TestProj
Ran 1 test in 0.004s
FAILED (failures=1)
False != True
Expected :True
Actual :False
<Click to see difference>
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.1.1\plugins\python-ce\helpers\pycharm\teamcity\diff_tools.py", line 32, in _patched_equals
old(self, first, second, msg)
File "C:\Users\Bill\AppData\Local\Programs\Python\Python38-32\lib\unittest\case.py", line 912, in assertEqual
assertion_func(first, second, msg=msg)
File "C:\Users\Bill\AppData\Local\Programs\Python\Python38-32\lib\unittest\case.py", line 905, in _baseAssertEqual
raise self.failureException(msg)
AssertionError: True != False
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Bill\AppData\Local\Programs\Python\Python38-32\lib\unittest\case.py", line 60, in testPartExecutor
yield
File "C:\Users\Bill\AppData\Local\Programs\Python\Python38-32\lib\unittest\case.py", line 676, in run
self._callTestMethod(testMethod)
File "C:\Users\Bill\AppData\Local\Programs\Python\Python38-32\lib\unittest\case.py", line 633, in _callTestMethod
method()
File "C:\Users\Bill\PycharmProjects\TestProj\test_unittest.py", line 6, in test_something
self.assertEqual(True, False)
Process finished with exit code 1
Assertion failed
Assertion failed
Assertion failed
Assertion failed
Assertion failed
Assertion failed
请先登录再写评论。
I get this all the time when tests fail in PyCharm, no matter which test runner I use. By contrast, running the same tests from the command line gives normal, usable output.
Perhaps I am missing some setting, but web search on this has so far been unsuccessful.
I see the same problem, but want to add it also fails to perform any subsequence tests.
The original problem seems similar to https://youtrack.jetbrains.com/issue/PY-45405
>but want to add it also fails to perform any subsequence tests
That's probably unrelated to the output, could you please create a ticket in our bug tracker and describe your case in the more details?
Looks like same here. With same test code run I see:
...
False != True
Expected :True
Actual :False
<Click to see difference>
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/teamcity/diff_tools.py", line 32, in _patched_equals
old(self, first, second, msg)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/unittest/case.py", line 839, in assertEqual
assertion_func(first, second, msg=msg)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/unittest/case.py", line 832, in _baseAssertEqual
raise self.failureException(msg)
AssertionError: True != False
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/unittest/case.py", line 59, in testPartExecutor
yield
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/unittest/case.py", line 615, in run
testMethod()
File "/Users/obelix/PycharmProjects/untiteled/test3.py", line 6, in test_something
self.assertEqual(True, False)
Ran 1 test in 0.005s
FAILED (failures=1)
Process finished with exit code 1
Assertion failed
Assertion failed
Assertion failed