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

Function test_wrap_file

tests/test_progress.py:629–644  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

627
628
629def test_wrap_file() -> None:
630 fd, filename = tempfile.mkstemp()
631 with os.fdopen(fd, "wb") as f:
632 total = f.write(b"Hello, World!")
633 try:
634 with open(filename, "rb") as file:
635 with rich.progress.wrap_file(file, total=total) as f:
636 assert f.read() == b"Hello, World!"
637 assert f.mode == "rb"
638 assert f.name == filename
639 assert f.closed
640 assert not f.handle.closed
641 assert not file.closed
642 assert file.closed
643 finally:
644 os.remove(filename)
645
646
647def test_wrap_file_task_total() -> None:

Callers

nothing calls this directly

Calls 4

openFunction · 0.85
wrap_fileMethod · 0.80
writeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected