From cf0da04dca7a5fcb3f20ab6a4eb78faf9dac8ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Sat, 13 Feb 2016 15:42:27 +0100 Subject: [PATCH] Print test comments when external tests fail Makes it easier to locate the failing tests in the test file --- ext_tests.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ext_tests.py b/ext_tests.py index 5e5ded8..0e1404c 100755 --- a/ext_tests.py +++ b/ext_tests.py @@ -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):