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()