From dfeff5713cb2483459a658effca2dd064643cdcd Mon Sep 17 00:00:00 2001 From: Maximilien Rigaut Date: Mon, 16 May 2022 01:03:45 +0200 Subject: [PATCH] Corrected Broken Tests With SystemExit --- tests/modules/test_config.py | 4 ++-- tests/modules/test_environmemt.py | 4 ++-- tests/modules/test_error_mngr.py | 4 ++-- tests/modules/test_preparser.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/modules/test_config.py b/tests/modules/test_config.py index ffade17..d404839 100644 --- a/tests/modules/test_config.py +++ b/tests/modules/test_config.py @@ -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"}} diff --git a/tests/modules/test_environmemt.py b/tests/modules/test_environmemt.py index f199613..69bef8f 100644 --- a/tests/modules/test_environmemt.py +++ b/tests/modules/test_environmemt.py @@ -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 diff --git a/tests/modules/test_error_mngr.py b/tests/modules/test_error_mngr.py index 1df95f1..4a2c8c0 100644 --- a/tests/modules/test_error_mngr.py +++ b/tests/modules/test_error_mngr.py @@ -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: diff --git a/tests/modules/test_preparser.py b/tests/modules/test_preparser.py index e2b23c2..2af9f2f 100644 --- a/tests/modules/test_preparser.py +++ b/tests/modules/test_preparser.py @@ -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)