Skip to content

Commit eb99c73

Browse files
committed
test deprecated call
1 parent 951627c commit eb99c73

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

tests/accelerators/test_tpu.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,6 @@ def test_accelerator_tpu(accelerator, devices):
102102
assert isinstance(trainer.accelerator, TPUAccelerator)
103103
assert isinstance(trainer.strategy, TPUSpawnStrategy)
104104
assert trainer.num_devices == 8
105-
with pytest.deprecated_call(
106-
match="`Trainer.tpu_cores` is deprecated in v1.6 and will be removed in v1.8. "
107-
"Please use `Trainer.devices` instead."
108-
):
109-
trainer.tpu_cores == 8
110105

111106

112107
@RunIf(tpu=True)
@@ -124,6 +119,7 @@ def test_accelerator_tpu_with_tpu_cores_priority():
124119
@RunIf(tpu=True)
125120
def test_set_devices_if_none_tpu():
126121
trainer = Trainer(accelerator="tpu", tpu_cores=8)
122+
assert isinstance(trainer.accelerator, TPUAccelerator)
127123
assert trainer.num_devices == 8
128124

129125

tests/deprecated_api/test_remove_1-8.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,3 +1106,14 @@ def on_save_checkpoint(self, trainer, pl_module, checkpoint):
11061106

11071107
trainer.callbacks = [TestCallbackSaveHookOverride()]
11081108
trainer.save_checkpoint(tmpdir + "/pathok.ckpt")
1109+
1110+
1111+
def test_trainer_tpu_cores(monkeypatch):
1112+
monkeypatch.setattr(pytorch_lightning.accelerators.tpu.TPUAccelerator, "is_available", lambda: True)
1113+
monkeypatch.setattr(pytorch_lightning.accelerators.tpu.TPUAccelerator, "parse_devices", lambda: 8)
1114+
trainer = Trainer(accelerator="TPU", devices=8)
1115+
with pytest.deprecated_call(
1116+
match="`Trainer.tpu_cores` is deprecated in v1.6 and will be removed in v1.8. "
1117+
"Please use `Trainer.devices` instead."
1118+
):
1119+
trainer.tpu_cores == 8

0 commit comments

Comments
 (0)