How to customize progress bar in test mode?

Hi,
I want to customize a progress bar for testing. I used the documentation to write the following, however nothing is printed to the screen.

I am using lightning version 1.7.7, pycharm and python3.7.5. Thanks!

class LitProgressBar(ProgressBarBase):

def __init__(self):
    super().__init__()  # don't forget this :)
    self.enable = True

def disable(self):
    self.enable = False

def on_test_batch_end(
    self,
    trainer: "pl.Trainer",
    pl_module: "pl.LightningModule",
    outputs: Optional[STEP_OUTPUT],
    batch: Any,
    batch_idx: int,
    dataloader_idx: int,
) -> None:
    super().on_test_batch_end(trainer, pl_module, outputs, batch, batch_idx,dataloader_idx)
    percent = (self.test_batch_idx / self.trainer.num_test_batches[0]) * 100
    sys.stdout.flush()
    sys.stdout.write(f'{percent:.01f} percent complete \r')

def get_metrics(self, trainer, model):
    # don't show the version number
    items = super().get_metrics(trainer, model)
    items.pop("v_num", None)
    return items

bar = LitProgressBar()
trainer = Trainer(callbacks=[bar])