Corrected Broken Tests With SystemExit
This commit is contained in:
parent
411b7ae512
commit
dfeff5713c
|
|
@ -34,7 +34,7 @@ def test_config_load():
|
|||
assert usr_c["aliases"]["aliases"]["test_alias"] == "test_parser"
|
||||
with pytest.raises(KeyError):
|
||||
assert usr_c["aliases"]["aliases"]["test_alias2"] is not None
|
||||
with pytest.raises(FileNotFoundError):
|
||||
with pytest.raises(SystemExit): # Not FileNotFoundError
|
||||
assert usr_c["aliases2"] is not None
|
||||
assert usr_c.__repr__()
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ def test_add_to_config():
|
|||
"parser": {"name": "test_parser", "type": "test_parser"}}
|
||||
assert from_list["parser_config"] == {"parser": {"name": "test_parser", "type": "test_parser"}}
|
||||
|
||||
with pytest.raises(FileNotFoundError):
|
||||
with pytest.raises(SystemExit): # Not FileNotFoundError
|
||||
assert from_empty["aliases"]
|
||||
from_empty.add_folder(user_conf)
|
||||
assert from_empty["aliases"] == {"aliases": {"test_alias": "test_parser"}}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ def test_getter():
|
|||
|
||||
try:
|
||||
test_check.purposefully_non_existing_parameter
|
||||
except AttributeError:
|
||||
except SystemExit:
|
||||
pass
|
||||
except Exception:
|
||||
assert False # Not AttributeError when getting non-existing parameter
|
||||
|
|
@ -86,7 +86,7 @@ def test_setter():
|
|||
|
||||
try:
|
||||
test_check.purposefully_non_existing_parameter = "test_value"
|
||||
except AttributeError:
|
||||
except SystemExit:
|
||||
pass
|
||||
except Exception:
|
||||
assert False # Not AttributeError when getting non-existing parameter
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ class TestLogging(TestCase):
|
|||
def test_log_exception(self):
|
||||
with self.assertLogs() as captured:
|
||||
with pytest.raises(SystemExit):
|
||||
error_mngr.log_exception(Exception, level="CRITICAL")
|
||||
self.assertEqual(len(captured.records), 1)
|
||||
error_mngr.log_exception(Exception(''), level="CRITICAL")
|
||||
self.assertEqual(2, len(captured.records))
|
||||
|
||||
def test_log_exception_with_message(self):
|
||||
for exception in all_non_blocking_exception_tests:
|
||||
|
|
|
|||
|
|
@ -280,13 +280,13 @@ def test_errors():
|
|||
pp = preparser.PreParser("not_existing_file.bprr", env)
|
||||
pp.readlines()
|
||||
|
||||
with pytest.raises(ImportError):
|
||||
with pytest.raises(SystemExit): # Not ImportError
|
||||
nofile = temp_name("real_file.bpr")
|
||||
make_new_file(nofile, "::< not_existing_file.bpr >")
|
||||
pp = preparser.PreParser(nofile, env)
|
||||
pp.make_import_list()
|
||||
|
||||
with pytest.raises(RecursionError):
|
||||
with pytest.raises(SystemExit): # Not RecursionError
|
||||
path = temp_name("test_recursion_error.bpr")
|
||||
make_new_file(path, "::< test_recursion_error.bpr >")
|
||||
pp = preparser.PreParser(path, env)
|
||||
|
|
|
|||
Loading…
Reference in New Issue