From 4c6e6685da67c76029d7aa47a3a2bb8f1abf7850 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 15 Dec 2023 15:00:34 +0100 Subject: [PATCH] remove flakey test --- pytest_abra/coordinator.py | 7 +------ tests/test_coordinator.py | 19 +++---------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/pytest_abra/coordinator.py b/pytest_abra/coordinator.py index ca75f98..6704360 100644 --- a/pytest_abra/coordinator.py +++ b/pytest_abra/coordinator.py @@ -112,11 +112,6 @@ class Coordinator: load_json_to_environ(test_credentials_path) - @staticmethod - def add_to_sys(path: Path): - # this is a function so that it can be monkeypatched - sys.path.append(path.as_posix()) - @staticmethod def create_runner_dict(recipes_dir: Path) -> dict[str, type[Runner]]: """Creates a dictionary holding all the RunnerClasses that can be discovered in recipes_dir @@ -136,7 +131,7 @@ class Coordinator: runner_discovery_pattern = re.compile("Runner.+") # make it possible to import modules from recipes_dir - Coordinator.add_to_sys(recipes_dir) + sys.path.append(recipes_dir.as_posix()) for module_path in recipes_dir.rglob("*/runner_*.py"): rel_path = module_path.relative_to(recipes_dir).as_posix().replace("/", ".").replace(".py", "") diff --git a/tests/test_coordinator.py b/tests/test_coordinator.py index a587d97..08b7975 100644 --- a/tests/test_coordinator.py +++ b/tests/test_coordinator.py @@ -37,13 +37,6 @@ def tmp_recipes(tmp_path_factory: pytest.TempPathFactory) -> Path: return tmp_recipes_target -def test_runner_runner_dict_import(tmp_recipes: Path): - """import from recipes dict should work, because create_runner_dict has sys.path.append""" - - RUNNER_DICT = Coordinator.create_runner_dict(tmp_recipes) - assert len(RUNNER_DICT.keys()) > 0 - - @pytest.fixture def clear_sys_path(): """clear sys.path before test, restore after""" @@ -53,14 +46,8 @@ def clear_sys_path(): sys.path.extend(syspath_copy) -def test_runner_runner_dict_import_failing(tmp_recipes: Path, clear_sys_path, monkeypatch): +def test_runner_runner_dict_import(tmp_recipes: Path, clear_sys_path): """import from recipes dict should work, because create_runner_dict has sys.path.append""" - monkeypatch.setattr( - Coordinator, - "add_to_sys", - lambda x: x, - ) - - with pytest.raises(ModuleNotFoundError): - Coordinator.create_runner_dict(tmp_recipes) + RUNNER_DICT = Coordinator.create_runner_dict(tmp_recipes) + assert len(RUNNER_DICT.keys()) > 0