def test_tqdm_progress_bar_progress_refresh(tmp_path, refresh_rate: int):
    """Test that the three progress bars get correctly updated when using different refresh rates."""
    model = BoringModel()

    class CurrentProgressBar(TQDMProgressBar):
        train_batches_seen = 0
        val_batches_seen = 0
        test_batches_seen = 0

        def on_train_batch_end(self, *args):
            super().on_train_batch_end(*args)
            self.train_batches_seen += 1

        def on_validation_batch_end(self, *args):
            super().on_validation_batch_end(*args)
            self.val_batches_seen += 1

        def on_test_batch_end(self, *args):
            super().on_test_batch_end(*args)
            self.test_batches_seen += 1

    pbar = CurrentProgressBar(refresh_rate=refresh_rate)
    trainer = Trainer(
        default_root_dir=tmp_path,
        callbacks=[pbar],
        limit_train_batches=1.0,
        num_sanity_val_steps=2,
        max_epochs=3,
    )
    assert trainer.progress_bar_callback.refresh_rate == refresh_rate

    trainer.fit(model)
    assert pbar.train_batches_seen == 3 * pbar.train_progress_bar.total
    assert pbar.val_batches_seen == 3 * pbar.val_progress_bar.total + trainer.num_sanity_val_steps
    assert pbar.test_batches_seen == 0

    trainer.validate(model)
    assert pbar.train_batches_seen == 3 * pbar.train_progress_bar.total
    assert pbar.val_batches_seen == 4 * pbar.val_progress_bar.total + trainer.num_sanity_val_steps
    assert pbar.test_batches_seen == 0

    trainer.test(model)
    assert pbar.train_batches_seen == 3 * pbar.train_progress_bar.total
    assert pbar.val_batches_seen == 4 * pbar.val_progress_bar.total + trainer.num_sanity_val_steps
    assert pbar.test_batches_seen == pbar.test_progress_bar.total
Test that the three progress bars get correctly updated when using different refresh rates.
tests/tests_pytorch/callbacks/progress/test_tqdm_progress_bar.py