Print test comments when external tests fail

Makes it easier to locate the failing tests in the test file
This commit is contained in:
Stefan Kögl
2016-02-13 15:42:27 +01:00
parent 4443d3241b
commit cf0da04dca

View File

@@ -60,12 +60,15 @@ class TestCaseTemplate(unittest.TestCase):
)
else:
res = jsonpatch.apply_patch(test['doc'], test['patch'])
try:
res = jsonpatch.apply_patch(test['doc'], test['patch'])
except jsonpatch.JsonPatchException as jpe:
raise Exception(test.get('comment', '')) from jpe
# if there is no 'expected' we only verify that applying the patch
# does not raies an exception
if 'expected' in test:
self.assertEquals(res, test['expected'])
self.assertEquals(res, test['expected'], test.get('comment', ''))
def make_test_case(tests):