import unittest from _ctypes import ArgumentError from tudelft.utilities.exception.ExceptionContainer import ExceptionContainer import json trace1: str = "Traceback (most recent call last):\n File '', line 1, in \nAttributeError: dsds" trace2:str='"Traceback (most recent call last):\n File "/tmp/PythonVenvs/failingtest100targz/lib/python3.8/site-packages/testcode/failingTest.py", line 33, in test\n runTests(FailingTest)\n File "/tmp/PythonVenvs/failingtest100targz/lib/python3.8/site-packages/unitpy/Runner.py", line 77, in runTests\n getRunWith(clazz)(clazz).run()\n File "/tmp/PythonVenvs/failingtest100targz/lib/python3.8/site-packages/unitpy/Runner.py", line 85, in run\n self._runall([])\n File "/tmp/PythonVenvs/failingtest100targz/lib/python3.8/site-packages/unitpy/Runner.py", line 50, in _runall\n m()\n File "/tmp/PythonVenvs/failingtest100targz/lib/python3.8/site-packages/testcode/failingTest.py", line 23, in failedtest\n raise AssertionError("this is wrong")\nAssertionError: this is wrong"' class ExceptionContainerTest(unittest.TestCase): def testSmoke(self): c=ExceptionContainer.create(trace1) print(str(c)) def testType(self): c=ExceptionContainer.create(trace1) self.assertEqual("AttributeError",c.getClassName()) def testMessage(self): c=ExceptionContainer.create(trace1) self.assertEqual(" dsds",c.getMessage()) def testLargerMessage(self): c=ExceptionContainer.create(trace2) print("warning: below looks like a message from else but it's the contained trace2") print(str(c)) def testToJson(self): c=ExceptionContainer.create(trace1) print(json.dumps(c.toJson()))