From 2ed1e8b8e70039d5d1993f5d85c45d9409aafd6a Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Fri, 20 Mar 2020 12:42:46 -0400 Subject: [PATCH] Fix detection of compiler bugs in `cant_compile` --- tests/compilers/test_ast.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/compilers/test_ast.py b/tests/compilers/test_ast.py index be46303..20b9aaa 100644 --- a/tests/compilers/test_ast.py +++ b/tests/compilers/test_ast.py @@ -7,7 +7,7 @@ from __future__ import unicode_literals from hy import HyString from hy.compiler import hy_compile, hy_eval -from hy.errors import HyCompileError, HyLanguageError, HyError +from hy.errors import HyLanguageError, HyError from hy.lex import hy_parse from hy.lex.exceptions import LexException, PrematureEndOfInput from hy._compat import PY36 @@ -36,14 +36,11 @@ def can_eval(expr): def cant_compile(expr): with pytest.raises(HyError) as excinfo: hy_compile(hy_parse(expr), __name__) - - if issubclass(excinfo.type, HyLanguageError): - assert excinfo.value.msg - return excinfo.value - elif issubclass(excinfo.type, HyCompileError): - # Anything that can't be compiled should raise a user friendly - # error, otherwise it's a compiler bug. - return excinfo.value + # Anything that can't be compiled should raise a user friendly + # error, otherwise it's a compiler bug. + assert issubclass(excinfo.type, HyLanguageError) + assert excinfo.value.msg + return excinfo.value def s(x):