I have looked at the other related questions here but have not found my answer. I would like to simplify the output of my Python (2.7) unittests. Trying sys.tracebacklimit = 0
did not work.
Here is my code snippet (the real code generates lots of similar tests):
#!/usr/bin/python -E
import unittest
import os
import sys
class TestSequense(unittest.TestCase):
pass
def test_dir_exists(dir):
def test(self):
self.assertTrue(os.path.isdir(dir),"ERROR: " + dir + " is not a directory")
return test
if __name__ == '__main__':
test = test_dir_exists("/something/not/set/correctly")
setattr(TestSequense, "test_path", test)
#TODO trying remove unnecessary traceback info... still not working
sys.tracebacklimit = 0
unittest.main()
The output is currently:
F
======================================================================
FAIL: test_path (__main__.TestSequense)
----------------------------------------------------------------------
Traceback (most recent call last):
File "./simple_unittest.py", line 11, in test
self.assertTrue(os.path.isdir(dir),"ERROR: " + dir + " is not a directory")
AssertionError: ERROR: /something/not/set/correctly is not a directory
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (failures=1)
I would like it to look like this:
F
======================================================================
FAIL: test_path (__main__.TestSequense)
----------------------------------------------------------------------
AssertionError: ERROR: /something/not/set/correctly is not a directory
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (failures=1)
Is this possible without parsing the output? The Traceback gives me no useful information and I am running 1000's of tests.
Thanks in advance!