diff --git a/codewars_test/test_framework.py b/codewars_test/test_framework.py index 50b9f85..cbe0993 100644 --- a/codewars_test/test_framework.py +++ b/codewars_test/test_framework.py @@ -51,8 +51,8 @@ def expect_error(message, function, exception=Exception): function() except exception: passed = True - except Exception: - pass + except Exception as e: + message = "{}: {} should be {}".format(message or "Unexpected exception", repr(e), repr(exception)) expect(passed, message) @@ -62,7 +62,7 @@ def expect_no_error(message, function, exception=BaseException): except exception as e: fail("{}: {}".format(message or "Unexpected exception", repr(e))) return - except Exception: + except: pass pass_() diff --git a/tests/fixtures/expect_error_sample.expected.txt b/tests/fixtures/expect_error_sample.expected.txt index b2c7f56..b0cb56d 100644 --- a/tests/fixtures/expect_error_sample.expected.txt +++ b/tests/fixtures/expect_error_sample.expected.txt @@ -25,15 +25,15 @@ Test Passed -f1 did not raise ArithmeticError +f1 did not raise ArithmeticError: Exception() should be -f1 did not raise ZeroDivisionError +f1 did not raise ZeroDivisionError: Exception() should be -f1 did not raise LookupError +f1 did not raise LookupError: Exception() should be -f1 did not raise KeyError +f1 did not raise KeyError: Exception() should be -f1 did not raise OSError +f1 did not raise OSError: Exception() should be 0.02 @@ -47,11 +47,11 @@ Test Passed -f2 did not raise LookupError +f2 did not raise LookupError: ZeroDivisionError('integer division or modulo by zero') should be -f2 did not raise KeyError +f2 did not raise KeyError: ZeroDivisionError('integer division or modulo by zero') should be -f2 did not raise OSError +f2 did not raise OSError: ZeroDivisionError('integer division or modulo by zero') should be 0.02 @@ -61,16 +61,16 @@ Test Passed -f3 did not raise ArithmeticError +f3 did not raise ArithmeticError: KeyError(1) should be -f3 did not raise ZeroDivisionError +f3 did not raise ZeroDivisionError: KeyError(1) should be Test Passed Test Passed -f3 did not raise OSError +f3 did not raise OSError: KeyError(1) should be 0.02 -0.11 +0.11 \ No newline at end of file diff --git a/tests/test_outputs.py b/tests/test_outputs.py index bfe8396..e35f8a2 100644 --- a/tests/test_outputs.py +++ b/tests/test_outputs.py @@ -20,9 +20,11 @@ def test(self): ) with open(expected_file, "r", encoding="utf-8") as r: # Allow duration to change + expected = re.sub(r"([()])", r"\\\1", r.read()) expected = re.sub( - r"(?<=)\d+(?:\.\d+)?", r"\\d+(?:\\.\\d+)?", r.read() + r"(?<=)\d+(?:\.\d+)?", r"\\d+(?:\\.\\d+)?", expected ) + self.assertRegex(result.stdout.decode("utf-8"), expected) return test