Skip to content

Commit cc1f757

Browse files
committed
strengthen tests to assure length of errors, testing both .__call__() and .run()
1 parent 36dc5f1 commit cc1f757

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/test_asteval.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,13 @@ def test_no_duplicate_exception(nested):
15261526
""" test that errors are not repeated GH #132
15271527
"""
15281528
interp = make_interpreter(nested_symtable=nested)
1529-
interp.run("print(hi)", with_raise = False)
1529+
interp.run("print(hi)", with_raise=False)
1530+
assert len(interp.error) == 1
1531+
assert interp.error[0].exc == NameError
1532+
1533+
# with plain eval too
1534+
interp.error = []
1535+
interp("print(hi)", raise_errors=False)
15301536
assert len(interp.error) == 1
15311537
assert interp.error[0].exc == NameError
15321538

@@ -1535,13 +1541,14 @@ def test_raise_errors_unknown_symbol(nested):
15351541
""" test that raise_error raises corret error type. GH #133
15361542
"""
15371543
interp = make_interpreter(nested_symtable=nested)
1544+
interp.error = []
15381545
try:
15391546
saw_exception = False
15401547
interp.run("unknown_value", with_raise=True)
15411548
except NameError:
15421549
saw_exception = True
15431550
assert saw_exception
1544-
assert len(interp.error) > 0
1551+
assert len(interp.error) == 1
15451552
assert interp.error[0].exc == NameError
15461553

15471554

0 commit comments

Comments
 (0)