Make Python unittest show AssertionError but no Traceback

后端 未结 3 2103
猫巷女王i
猫巷女王i 2021-01-04 18:56

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.tracebackl

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-04 19:51

    unittest has a mechanism for hiding the contents of the TestCase.assert* methods in the traceback, as those really don't contain any useful information for failures. It looks for __unittest in the frame's globals. You can hide an entire module from the tracebacks by putting __unittest = True at the top of the module.

提交回复
热议问题