From 9b8686bd83e2bc243cf329e26f1c667c6949cf67 Mon Sep 17 00:00:00 2001 From: Brendan Fahy Date: Sat, 8 Aug 2020 18:16:42 +0000 Subject: [PATCH] make it a fixture --- tests/trainer/test_trainer.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/trainer/test_trainer.py b/tests/trainer/test_trainer.py index 2418f6fc516d2c..2466aef99601d7 100644 --- a/tests/trainer/test_trainer.py +++ b/tests/trainer/test_trainer.py @@ -990,16 +990,19 @@ def setup(self, stage): assert trainer.get_model().stage == 'test' -def test_trainer_ensure_no_local_only_file_ops(tmpdir, monkeypatch): +@pytest.fixture +def no_local_file_ops(monkeypatch): + monkeypatch.delattr(os.path, "exists") + monkeypatch.delattr(os.path, "isdir") + + +def test_trainer_ensure_no_local_only_file_ops(tmpdir, monkeypatch, no_local_file_ops): """Currently file ops use helpers in cloud_io to ensure thigns work with local or remote files We will monkeypatch to disable some problematic local only methods to hopefully prevent any file ops from being added which only work locally """ monkeypatch.setenv('TORCH_HOME', str(tmpdir)) - monkeypatch.delattr(os.path, "exists") - monkeypatch.delattr(os.path, "isdir") - monkeypatch.delattr(os.path, "isfile") model = EvalModelTemplate()