Rev | Line | |
---|
[1392] | 1 | import unittest
|
---|
| 2 | from _ctypes import ArgumentError
|
---|
| 3 | from tudelft.utilities.exception.ExceptionContainer import ExceptionContainer
|
---|
| 4 | import json
|
---|
| 5 |
|
---|
| 6 |
|
---|
| 7 | trace1: str = "Traceback (most recent call last):\n File '<stdin>', line 1, in <module>\nAttributeError: dsds"
|
---|
| 8 | 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"'
|
---|
| 9 |
|
---|
| 10 |
|
---|
| 11 | class ExceptionContainerTest(unittest.TestCase):
|
---|
| 12 |
|
---|
| 13 | def testSmoke(self):
|
---|
| 14 | c=ExceptionContainer.create(trace1)
|
---|
| 15 | print(str(c))
|
---|
| 16 |
|
---|
| 17 | def testType(self):
|
---|
| 18 | c=ExceptionContainer.create(trace1)
|
---|
| 19 | self.assertEqual("AttributeError",c.getClassName())
|
---|
| 20 |
|
---|
| 21 | def testMessage(self):
|
---|
| 22 | c=ExceptionContainer.create(trace1)
|
---|
| 23 | self.assertEqual(" dsds",c.getMessage())
|
---|
| 24 |
|
---|
| 25 | def testLargerMessage(self):
|
---|
| 26 | c=ExceptionContainer.create(trace2)
|
---|
| 27 | print("warning: below looks like a message from else but it's the contained trace2")
|
---|
| 28 | print(str(c))
|
---|
| 29 |
|
---|
| 30 | def testToJson(self):
|
---|
| 31 | c=ExceptionContainer.create(trace1)
|
---|
| 32 | print(json.dumps(c.toJson()))
|
---|
Note:
See
TracBrowser
for help on using the repository browser.