Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
import torch.multiprocessing as mp


@pytest.fixture(scope="function", autouse=True)
def preserve_global_rank_variable():
""" Ensures that the rank_zero_only.rank global variable gets reset in each test. """
from pytorch_lightning.utilities.distributed import rank_zero_only
rank = getattr(rank_zero_only, "rank", None)
yield
if rank is not None:
setattr(rank_zero_only, "rank", rank)


@pytest.fixture(scope="function", autouse=True)
def restore_env_variables():
""" Ensures that environment variables set during the test do not leak out. """
Expand Down