MCPcopy
hub / github.com/Textualize/rich / test_progress_max_refresh

Function test_progress_max_refresh

tests/test_progress.py:490–527  ·  view source on GitHub ↗

Test max_refresh argument.

()

Source from the content-addressed store, hash-verified

488
489
490def test_progress_max_refresh() -> None:
491 """Test max_refresh argument."""
492 time = 0.0
493
494 def get_time() -> float:
495 nonlocal time
496 try:
497 return time
498 finally:
499 time = time + 1.0
500
501 console = Console(
502 color_system=None,
503 width=80,
504 legacy_windows=False,
505 force_terminal=True,
506 _environ={},
507 )
508 column = TextColumn("{task.description}")
509 column.max_refresh = 3
510 progress = Progress(
511 column,
512 get_time=get_time,
513 auto_refresh=False,
514 console=console,
515 )
516 console.begin_capture()
517 with progress:
518 task_id = progress.add_task("start")
519 for tick in range(6):
520 progress.update(task_id, description=f"tick {tick}")
521 progress.refresh()
522 result = console.end_capture()
523 print(repr(result))
524 assert (
525 result
526 == "\x1b[?25l\r\x1b[2Kstart\r\x1b[2Kstart\r\x1b[2Ktick 1\r\x1b[2Ktick 1\r\x1b[2Ktick 3\r\x1b[2Ktick 3\r\x1b[2Ktick 5\r\x1b[2Ktick 5\n\x1b[?25h"
527 )
528
529
530def test_live_is_started_if_progress_is_enabled() -> None:

Callers

nothing calls this directly

Calls 9

begin_captureMethod · 0.95
add_taskMethod · 0.95
updateMethod · 0.95
refreshMethod · 0.95
end_captureMethod · 0.95
ConsoleClass · 0.90
TextColumnClass · 0.90
ProgressClass · 0.90
printFunction · 0.50

Tested by

no test coverage detected