Skip to content

Commit ae098f2

Browse files
committed
add testing
1 parent a52381f commit ae098f2

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/tests_pytorch/callbacks/progress/test_rich_progress_bar.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,3 +577,31 @@ def test_rich_progress_bar_metrics_theme_update(*_):
577577
theme = RichProgressBar(theme=RichProgressBarTheme(metrics_format=".3e", metrics_text_delimiter="\n")).theme
578578
assert theme.metrics_format == ".3e"
579579
assert theme.metrics_text_delimiter == "\n"
580+
581+
582+
@RunIf(rich=True)
583+
def test_rich_progress_bar_empty_val_dataloader_model(tmp_path):
584+
"""Test that RichProgressBar doesn't crash with empty val_dataloader list from model."""
585+
586+
class EmptyListModel(BoringModel):
587+
def train_dataloader(self):
588+
return DataLoader(RandomDataset(32, 64), batch_size=2)
589+
590+
def val_dataloader(self):
591+
return []
592+
593+
model = EmptyListModel()
594+
progress_bar = RichProgressBar()
595+
596+
trainer = Trainer(
597+
default_root_dir=tmp_path,
598+
max_epochs=1,
599+
num_sanity_val_steps=1,
600+
callbacks=[progress_bar],
601+
limit_train_batches=2,
602+
enable_checkpointing=False,
603+
logger=False,
604+
)
605+
606+
# This should not raise an AssertionError
607+
trainer.fit(model)

0 commit comments

Comments
 (0)