Skip to content

Commit f694c31

Browse files
committed
Update test_remove_1-5.py
1 parent e4bc3ff commit f694c31

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

tests/deprecated_api/test_remove_1-5.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,53 @@ def test_v1_5_0_model_checkpoint_period(tmpdir):
212212
ModelCheckpoint(dirpath=tmpdir, period=1)
213213

214214

215+
def test_v1_5_0_old_on_train_epoch_end(tmpdir):
216+
callback_warning_cache.clear()
217+
218+
class OldSignature(Callback):
219+
220+
def on_train_epoch_end(self, trainer, pl_module, outputs): # noqa
221+
...
222+
223+
class OldSignatureModel(BoringModel):
224+
225+
def on_train_epoch_end(self, outputs): # noqa
226+
...
227+
228+
model = BoringModel()
229+
trainer = Trainer(default_root_dir=tmpdir, max_epochs=1, callbacks=OldSignature())
230+
231+
with pytest.deprecated_call(match="old signature will be removed in v1.5"):
232+
trainer.fit(model)
233+
234+
callback_warning_cache.clear()
235+
236+
model = OldSignatureModel()
237+
238+
with pytest.deprecated_call(match="old signature will be removed in v1.5"):
239+
trainer.fit(model)
240+
241+
trainer.train_loop.warning_cache.clear()
242+
243+
class NewSignature(Callback):
244+
245+
def on_train_epoch_end(self, trainer, pl_module):
246+
...
247+
248+
trainer.callbacks = [NewSignature()]
249+
with no_deprecated_call(match="`Callback.on_train_epoch_end` signature has changed in v1.3."):
250+
trainer.fit(model)
251+
252+
class NewSignatureModel(BoringModel):
253+
254+
def on_train_epoch_end(self):
255+
...
256+
257+
model = NewSignatureModel()
258+
with no_deprecated_call(match="`ModelHooks.on_train_epoch_end` signature has changed in v1.3."):
259+
trainer.fit(model)
260+
261+
215262
@pytest.mark.parametrize("cls", (BaseProfiler, SimpleProfiler, AdvancedProfiler, PyTorchProfiler))
216263
def test_v1_5_0_profiler_output_filename(tmpdir, cls):
217264
filepath = str(tmpdir / "test.txt")

0 commit comments

Comments
 (0)