Test max_refresh argument.
()
| 488 | |
| 489 | |
| 490 | def 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 | |
| 530 | def test_live_is_started_if_progress_is_enabled() -> None: |
nothing calls this directly
no test coverage detected