Fix detection of compiler bugs in cant_compile
This commit is contained in:
parent
5c9f04021e
commit
2ed1e8b8e7
@ -7,7 +7,7 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
from hy import HyString
|
from hy import HyString
|
||||||
from hy.compiler import hy_compile, hy_eval
|
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 import hy_parse
|
||||||
from hy.lex.exceptions import LexException, PrematureEndOfInput
|
from hy.lex.exceptions import LexException, PrematureEndOfInput
|
||||||
from hy._compat import PY36
|
from hy._compat import PY36
|
||||||
@ -36,14 +36,11 @@ def can_eval(expr):
|
|||||||
def cant_compile(expr):
|
def cant_compile(expr):
|
||||||
with pytest.raises(HyError) as excinfo:
|
with pytest.raises(HyError) as excinfo:
|
||||||
hy_compile(hy_parse(expr), __name__)
|
hy_compile(hy_parse(expr), __name__)
|
||||||
|
# Anything that can't be compiled should raise a user friendly
|
||||||
if issubclass(excinfo.type, HyLanguageError):
|
# error, otherwise it's a compiler bug.
|
||||||
assert excinfo.value.msg
|
assert issubclass(excinfo.type, HyLanguageError)
|
||||||
return excinfo.value
|
assert excinfo.value.msg
|
||||||
elif issubclass(excinfo.type, HyCompileError):
|
return excinfo.value
|
||||||
# Anything that can't be compiled should raise a user friendly
|
|
||||||
# error, otherwise it's a compiler bug.
|
|
||||||
return excinfo.value
|
|
||||||
|
|
||||||
|
|
||||||
def s(x):
|
def s(x):
|
||||||
|
Loading…
Reference in New Issue
Block a user