Skip to content

Commit

Permalink
xfail if not installed (#3860)
Browse files Browse the repository at this point in the history
include mkpatch


fix test
  • Loading branch information
awaelchli authored Oct 6, 2020
1 parent e6e5406 commit 6272fd3
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/loggers/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 6272fd3

Please sign in to comment.