Skip to content

Commit 4f88200

Browse files
committed
use monkeypatch context
1 parent b2697b5 commit 4f88200

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/tests_pytorch/trainer/connectors/test_accelerator_connector.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,12 +493,13 @@ def test_strategy_choice_ddp_torchelastic(_, __, mps_count_0, cuda_count_2):
493493
)
494494
def test_torchelastic_priority_over_slurm(monkeypatch):
495495
"""Test that the TorchElastic cluster environment is chosen over SLURM when both are detected."""
496-
mock_cuda_count(monkeypatch, 2)
497-
mock_mps_count(monkeypatch, 0)
498-
mock_hpu_count(monkeypatch, 0)
496+
with monkeypatch.context():
497+
mock_cuda_count(monkeypatch, 2)
498+
mock_mps_count(monkeypatch, 0)
499+
mock_hpu_count(monkeypatch, 0)
500+
connector = _AcceleratorConnector(strategy="ddp")
499501
assert TorchElasticEnvironment.detect()
500502
assert SLURMEnvironment.detect()
501-
connector = _AcceleratorConnector(strategy="ddp")
502503
assert isinstance(connector.strategy.cluster_environment, TorchElasticEnvironment)
503504

504505

0 commit comments

Comments
 (0)