샘플
rich 15.0.0: Render rich Console output to a string a test can assert on, and pin the escape codes, width, markup and highlighting that decide what the string holds
검증된 샘플 — pypi rich 15.0.0: Render rich Console output to a string a test can assert on, and pin the escape codes, width, markup and highlighting that decide…
sha256:3dae0c04df2ebeff413e9a4a6dc0213423def8b204f079fa3e738abce3780035
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 2
선언된 환경
python 3.12 linux x64 python 3.12 python pip
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| python 3.12 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1 |
2026-08-14 |
| python 3.12 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1 |
2026-08-18 |
케이스
HOW- 목표
- Render rich Console output to a string a test can assert on, and pin the escape codes, width, markup and highlighting that decide what the string holds
- 패키지
- 심벌
-
- rich.console.Console
- Console.capture
- Console.export_text
- force_terminal
- color_system
- rich.style.Style
- rich.table.Table
- rich.markup.escape
- rich.errors.MarkupError
- __rich__
- __rich_console__
- highlight
- 환경
- python 3.12
- 생성일
- 2026-08-14T13:20:38Z
컨트랙트
- assert a Console writing to a StringIO reports is_terminal False and color_system None, and emits the markup's text with no escape byte in it
- assert force_terminal=True on the same StringIO emits the bold escape sequence, so the codes are a setting rather than a property of the output
- assert TERM and COLORTERM decide which color_system is detected and COLORTERM outranks TERM, while neither moves the bytes for bold, which is an attribute and not a colour
- assert color_system is settled in the constructor where width is read at access time, so one console follows the environment for its width and ignores it for its colours
- assert FORCE_COLOR in the environment turns is_terminal on for a plain file, which is how a CI log fills with escape codes nobody asked for
- assert TTY_COMPATIBLE is read before FORCE_COLOR and 0 defeats it while 1 turns is_terminal on by itself, so that fix stops working in a runner exporting it
- assert TERM=dumb leaves is_terminal True while dropping color_system to None, so the two are separate switches
- assert no_color=True still emits the bold code and only color_system=None suppresses every escape sequence
- assert a Style keeps the codes it rendered first, so the console that renders a colour first fixes its bytes for the process and a later console with a different color_system repeats them
- assert console.capture() returns the rendered text and redirects rather than tees, so the console's own file receives nothing while the capture is open
- assert a capture keeps the escape codes the console would have written, so it is not a way to get plain text
- assert nested captures do not nest: the inner result holds everything printed since the outer block began and the outer result holds only what followed
- assert record=True with export_text clears the recording by default, so a second call returns an empty string
- assert os.get_terminal_size raises with no tty and the console falls back to width 80 by height 25
- assert COLUMNS overrides that fallback and is read at access time, so an existing console changes width when the environment does, while an explicit width= beats COLUMNS
- assert a small Table renders identically at 40, 80 and 120 columns because it measures its content, while expand=True and overflowing text are what follow the console width
- assert markup is interpreted by default and markup=False renders the tags literally, both per-call and per-console
- assert markup deletes user text without an error for list[int], for a bracketed sentence and for an unknown style name, on a console emitting codes as well as one that is not
- assert a stray closing tag raises rich.errors.MarkupError, which is a ConsoleError and not a ValueError, and that escape() or markup=False prevents it
- assert emoji codes are substituted by default and that a Text object is never parsed for markup
- assert console.print uses __rich__ first, then __rich_console__, and that __rich__ wins when both exist and is looked up on the instance
- assert an object with neither hook is rendered with str() and not repr(), while a container is pretty-printed with repr() on its items
- assert the str() branch skips markup and emoji parsing, so printing an object cannot be injected the way printing a string can, while the highlighter is the one rewrite it does not skip
- assert a string returned from __rich__ goes through the highlighter, which splits the markup's style run in two on the number inside it
- assert the highlighter styles a bare number, a number inside a sentence and the shape of a repr unless highlight=False
- assert highlight=False changes nothing on a console that emits no codes, because the highlighter still runs and its spans have nowhere to go
- assert rich exports no __version__, so the version has to come from importlib.metadata
파일
- csx.json
- requirements.txt
- src/__init__.py
- src/report.py
- test/contract.py