From e33341c537eb4f347810d94ea2f66c05c2d4a1fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20W=C3=A4lchli?= Date: Mon, 5 Oct 2020 04:11:32 +0200 Subject: [PATCH] xfail if not installed include mkpatch fix test --- tests/loggers/test_all.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/loggers/test_all.py b/tests/loggers/test_all.py index 6a9f3aa1c92ad..80453bbb658b2 100644 --- a/tests/loggers/test_all.py +++ b/tests/loggers/test_all.py @@ -157,15 +157,23 @@ def name(self): @pytest.mark.parametrize("logger_class", [ - TensorBoardLogger, CometLogger, MLFlowLogger, NeptuneLogger, + TensorBoardLogger, TestTubeLogger, # The WandbLogger gets tested for pickling in its own test. ]) -@mock.patch('pytorch_lightning.loggers.neptune.neptune') -def test_loggers_pickle(neptune, tmpdir, monkeypatch, logger_class): +def test_loggers_pickle_all(tmpdir, monkeypatch, logger_class): + """ Test that the logger objects can be pickled. This test only makes sense if the packages are installed. """ + _patch_comet_atexit(monkeypatch) + try: + _test_loggers_pickle(tmpdir, monkeypatch, logger_class) + except (ImportError, ModuleNotFoundError): + pytest.xfail(f"pickle test requires {logger_class.__class__} dependencies to be installed.") + + +def _test_loggers_pickle(tmpdir, monkeypatch, logger_class): """Verify that pickling trainer with logger works.""" _patch_comet_atexit(monkeypatch)