repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/progress.py
rich/progress.py
from __future__ import annotations import io import typing import warnings from abc import ABC, abstractmethod from collections import deque from dataclasses import dataclass, field from datetime import timedelta from io import RawIOBase, UnsupportedOperation from math import ceil from mmap import mmap from operator i...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
true
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/region.py
rich/region.py
from typing import NamedTuple class Region(NamedTuple): """Defines a rectangular region of the screen.""" x: int y: int width: int height: int
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/highlighter.py
rich/highlighter.py
import re from abc import ABC, abstractmethod from typing import List, Union from .text import Span, Text def _combine_regex(*regexes: str) -> str: """Combine a number of regexes in to a single regex. Returns: str: New regex with all regexes ORed together. """ return "|".join(regexes) clas...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_palettes.py
rich/_palettes.py
from .palette import Palette # Taken from https://en.wikipedia.org/wiki/ANSI_escape_code (Windows 10 column) WINDOWS_PALETTE = Palette( [ (12, 12, 12), (197, 15, 31), (19, 161, 14), (193, 156, 0), (0, 55, 218), (136, 23, 152), (58, 150, 221), (204, 2...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/pretty.py
rich/pretty.py
import builtins import collections import dataclasses import inspect import os import reprlib import sys from array import array from collections import Counter, UserDict, UserList, defaultdict, deque from dataclasses import dataclass, fields, is_dataclass from inspect import isclass from itertools import islice from t...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
true
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/__init__.py
rich/__init__.py
"""Rich text and beautiful formatting in the terminal.""" import os from typing import IO, TYPE_CHECKING, Any, Callable, Optional, Union from ._extension import load_ipython_extension # noqa: F401 __all__ = ["get_console", "reconfigure", "print", "inspect", "print_json"] if TYPE_CHECKING: from .console import ...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/protocol.py
rich/protocol.py
from typing import Any, cast, Set, TYPE_CHECKING from inspect import isclass if TYPE_CHECKING: from rich.console import RenderableType _GIBBERISH = """aihwerij235234ljsdnp34ksodfipwoe234234jlskjdf""" def is_renderable(check_object: Any) -> bool: """Check if an object may be rendered by Rich.""" return (...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/emoji.py
rich/emoji.py
import sys from typing import TYPE_CHECKING, Optional, Union, Literal from .jupyter import JupyterMixin from .segment import Segment from .style import Style from ._emoji_codes import EMOJI from ._emoji_replace import _emoji_replace if TYPE_CHECKING: from .console import Console, ConsoleOptions, RenderResult E...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/abc.py
rich/abc.py
from abc import ABC class RichRenderable(ABC): """An abstract base class for Rich renderables. Note that there is no need to extend this class, the intended use is to check if an object supports the Rich renderable protocol. For example:: if isinstance(my_object, RichRenderable): con...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_stack.py
rich/_stack.py
from typing import List, TypeVar T = TypeVar("T") class Stack(List[T]): """A small shim over builtin list.""" @property def top(self) -> T: """Get top of stack.""" return self[-1] def push(self, item: T) -> None: """Push an item on to the stack (append in stack nomenclature)...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/status.py
rich/status.py
from types import TracebackType from typing import Optional, Type from .console import Console, RenderableType from .jupyter import JupyterMixin from .live import Live from .spinner import Spinner from .style import StyleType class Status(JupyterMixin): """Displays a status indicator with a 'spinner' animation. ...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/json.py
rich/json.py
from pathlib import Path from json import loads, dumps from typing import Any, Callable, Optional, Union from .text import Text from .highlighter import JSONHighlighter, NullHighlighter class JSON: """A renderable which pretty prints JSON. Args: json (str): JSON encoded data. indent (Union[N...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/color.py
rich/color.py
import re import sys from colorsys import rgb_to_hls from enum import IntEnum from functools import lru_cache from typing import TYPE_CHECKING, NamedTuple, Optional, Tuple from ._palettes import EIGHT_BIT_PALETTE, STANDARD_PALETTE, WINDOWS_PALETTE from .color_triplet import ColorTriplet from .repr import Result, rich_...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/constrain.py
rich/constrain.py
from typing import Optional, TYPE_CHECKING from .jupyter import JupyterMixin from .measure import Measurement if TYPE_CHECKING: from .console import Console, ConsoleOptions, RenderableType, RenderResult class Constrain(JupyterMixin): """Constrain the width of a renderable to a given number of characters. ...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/text.py
rich/text.py
import re from functools import partial, reduce from math import gcd from operator import itemgetter from typing import ( TYPE_CHECKING, Any, Callable, Dict, Iterable, List, NamedTuple, Optional, Pattern, Tuple, Union, ) from ._loop import loop_last from ._pick import pick_b...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
true
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/ansi.py
rich/ansi.py
import re import sys from contextlib import suppress from typing import Iterable, NamedTuple, Optional from .color import Color from .style import Style from .text import Text re_ansi = re.compile( r""" (?:\x1b[0-?])| (?:\x1b\](.*?)\x1b\\)| (?:\x1b([(@-Z\\-_]|\[[0-?]*[ -/]*[@-~])) """, re.VERBOSE, ) class _...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/syntax.py
rich/syntax.py
from __future__ import annotations import os.path import re import sys import textwrap from abc import ABC, abstractmethod from pathlib import Path from typing import ( Any, Dict, Iterable, List, NamedTuple, Optional, Sequence, Set, Tuple, Type, Union, ) from pygments.lexer...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
true
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_cell_widths.py
rich/_cell_widths.py
# Auto generated by make_terminal_widths.py CELL_WIDTHS = [ (0, 0, 0), (1, 31, -1), (127, 159, -1), (173, 173, 0), (768, 879, 0), (1155, 1161, 0), (1425, 1469, 0), (1471, 1471, 0), (1473, 1474, 0), (1476, 1477, 0), (1479, 1479, 0), (1536, 1541, 0), (1552, 1562, 0), ...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/progress_bar.py
rich/progress_bar.py
import math from functools import lru_cache from time import monotonic from typing import Iterable, List, Optional from .color import Color, blend_rgb from .color_triplet import ColorTriplet from .console import Console, ConsoleOptions, RenderResult from .jupyter import JupyterMixin from .measure import Measurement fr...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_timer.py
rich/_timer.py
""" Timer context manager, only used in debug. """ from time import time import contextlib from typing import Generator @contextlib.contextmanager def timer(subject: str = "time") -> Generator[None, None, None]: """print the elapsed time. (only used in debugging)""" start = time() yield elapsed = t...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/repr.py
rich/repr.py
import inspect from functools import partial from typing import ( Any, Callable, Iterable, List, Optional, Tuple, Type, TypeVar, Union, overload, ) T = TypeVar("T") Result = Iterable[Union[Any, Tuple[Any], Tuple[str, Any], Tuple[str, Any, Any]]] RichReprResult = Result class...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_emoji_codes.py
rich/_emoji_codes.py
EMOJI = { "1st_place_medal": "🥇", "2nd_place_medal": "🥈", "3rd_place_medal": "🥉", "ab_button_(blood_type)": "🆎", "atm_sign": "🏧", "a_button_(blood_type)": "🅰", "afghanistan": "🇦🇫", "albania": "🇦🇱", "algeria": "🇩🇿", "american_samoa": "🇦🇸", "andorra": "🇦🇩", ...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
true
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/live_render.py
rich/live_render.py
from typing import Optional, Tuple, Literal from ._loop import loop_last from .console import Console, ConsoleOptions, RenderableType, RenderResult from .control import Control from .segment import ControlType, Segment from .style import StyleType from .text import Text VerticalOverflowMethod = Literal["crop", "elli...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/_extension.py
rich/_extension.py
from typing import Any def load_ipython_extension(ip: Any) -> None: # pragma: no cover # prevent circular import from rich.pretty import install from rich.traceback import install as tr_install install() tr_install()
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/rule.py
rich/rule.py
from typing import Union from .align import AlignMethod from .cells import cell_len, set_cell_size from .console import Console, ConsoleOptions, RenderResult from .jupyter import JupyterMixin from .measure import Measurement from .style import Style from .text import Text class Rule(JupyterMixin): """A console r...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/diagnose.py
rich/diagnose.py
import os import platform from rich import inspect from rich.console import Console, get_windows_console_features from rich.panel import Panel from rich.pretty import Pretty def report() -> None: # pragma: no cover """Print a report to the terminal with debugging information""" console = Console() inspe...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/style.py
rich/style.py
import sys from functools import lru_cache from operator import attrgetter from pickle import dumps, loads from random import randint from typing import Any, Dict, Iterable, List, Optional, Type, Union, cast from . import errors from .color import Color, ColorParseError, ColorSystem, blend_rgb from .repr import Result...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/padding.py
rich/padding.py
from typing import TYPE_CHECKING, List, Optional, Tuple, Union if TYPE_CHECKING: from .console import ( Console, ConsoleOptions, RenderableType, RenderResult, ) from .jupyter import JupyterMixin from .measure import Measurement from .segment import Segment from .style import St...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/rich/layout.py
rich/layout.py
from abc import ABC, abstractmethod from itertools import islice from operator import itemgetter from threading import RLock from typing import ( TYPE_CHECKING, Dict, Iterable, List, NamedTuple, Optional, Sequence, Tuple, Union, ) from ._ratio import ratio_resolve from .align import...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_theme.py
tests/test_theme.py
import io import os import tempfile import pytest from rich.style import Style from rich.theme import Theme, ThemeStack, ThemeStackError def test_inherit(): theme = Theme({"warning": "red"}) assert theme.styles["warning"] == Style(color="red") assert theme.styles["dim"] == Style(dim=True) def test_con...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_live.py
tests/test_live.py
# encoding=utf-8 import time from typing import Optional # import pytest from rich.console import Console from rich.live import Live from rich.text import Text def create_capture_console( *, width: int = 60, height: int = 80, force_terminal: Optional[bool] = True ) -> Console: return Console( width=w...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_color.py
tests/test_color.py
from rich.color import ( blend_rgb, parse_rgb_hex, Color, ColorParseError, ColorSystem, ColorType, ColorTriplet, ) from rich.style import Style from rich.text import Text, Span import pytest def test_str() -> None: assert str(Color.parse("red")) == "Color('red', ColorType.STANDARD, nu...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_highlighter.py
tests/test_highlighter.py
"""Tests for the highlighter classes.""" import json from typing import List import pytest from rich.highlighter import ( ISO8601Highlighter, JSONHighlighter, NullHighlighter, ReprHighlighter, ) from rich.text import Span, Text def test_wrong_type(): highlighter = NullHighlighter() with pyte...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_rich_print.py
tests/test_rich_print.py
import io import json import rich from rich.console import Console def test_get_console(): console = rich.get_console() assert isinstance(console, Console) def test_reconfigure_console(): rich.reconfigure(width=100) assert rich.get_console().width == 100 def test_rich_print(): console = rich....
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/render.py
tests/render.py
import io import re from rich.console import Console, RenderableType re_link_ids = re.compile(r"id=[\d.\-]*?;.*?\x1b") def replace_link_ids(render: str) -> str: """Link IDs have a random ID and system path which is a problem for reproducible tests. """ return re_link_ids.sub("id=0;foo\x1b", render...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_status.py
tests/test_status.py
from time import sleep from rich.console import Console from rich.spinner import Spinner from rich.status import Status def test_status(): console = Console( color_system=None, width=80, legacy_windows=False, get_time=lambda: 0.0 ) status = Status("foo", console=console) assert status.console...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_logging.py
tests/test_logging.py
import io import os import logging from typing import Optional import pytest from rich.console import Console from rich.logging import RichHandler handler = RichHandler( console=Console( file=io.StringIO(), force_terminal=True, width=80, color_system="truecolor", _environ=...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_pretty.py
tests/test_pretty.py
import collections import io import sys from array import array from collections import UserDict, defaultdict, deque from dataclasses import dataclass, field from typing import Any, List, NamedTuple import attr import pytest from rich.console import Console from rich.measure import Measurement from rich.pretty import...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_traceback.py
tests/test_traceback.py
import io import re import sys from typing import List import pytest from rich.console import Console from rich.theme import Theme from rich.traceback import Traceback, install def test_handler(): console = Console(file=io.StringIO(), width=100, color_system=None) expected_old_handler = sys.excepthook ...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_markdown_no_hyperlinks.py
tests/test_markdown_no_hyperlinks.py
# coding=utf-8 MARKDOWN = """Heading ======= Sub-heading ----------- ### Heading #### H4 Heading ##### H5 Heading ###### H6 Heading Paragraphs are separated by a blank line. Two spaces at the end of a line produces a line break. Text attributes _italic_, **bold**, `monospace`. Horizontal rule: --- Bulle...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_control.py
tests/test_control.py
from rich.control import Control, escape_control_codes, strip_control_codes from rich.segment import ControlType, Segment def test_control(): control = Control(ControlType.BELL) assert str(control) == "\x07" def test_strip_control_codes(): assert strip_control_codes("") == "" assert strip_control_co...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_progress.py
tests/test_progress.py
# encoding=utf-8 import io import os import tempfile from types import SimpleNamespace import pytest import rich.progress from rich.console import Console from rich.highlighter import NullHighlighter from rich.progress import ( BarColumn, DownloadColumn, FileSizeColumn, MofNCompleteColumn, Progre...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_syntax.py
tests/test_syntax.py
import io import os import sys import tempfile from importlib.metadata import Distribution import pytest from pygments.lexers import PythonLexer from rich.measure import Measurement from rich.panel import Panel from rich.style import Style from rich.syntax import ( ANSISyntaxTheme, Color, Console, Pyg...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
true
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_columns_align.py
tests/test_columns_align.py
# encoding=utf-8 import io from rich import box from rich.columns import Columns from rich.console import Console from rich.panel import Panel def render(): console = Console(file=io.StringIO(), width=100, legacy_windows=False) panel = Panel.fit("foo", box=box.SQUARE, padding=0) columns = Columns([panel...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_screen.py
tests/test_screen.py
from rich.console import Console from rich.screen import Screen def test_screen(): console = Console(color_system=None, width=20, height=5, legacy_windows=False) with console.capture() as capture: console.print(Screen("foo\nbar\nbaz\nfoo\nbar\nbaz\foo")) result = capture.get() print(repr(resul...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_layout.py
tests/test_layout.py
import sys import pytest from rich.console import Console from rich.layout import Layout, NoSplitter from rich.panel import Panel def test_no_layout(): layout = Layout() with pytest.raises(NoSplitter): layout.split(Layout(), Layout(), splitter="nope") def test_add_split(): layout = Layout() ...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_pick.py
tests/test_pick.py
from rich._pick import pick_bool def test_pick_bool(): assert pick_bool(False) == False assert pick_bool(True) == True assert pick_bool(None) == False assert pick_bool(False, True) == False assert pick_bool(None, True) == True assert pick_bool(True, None) == True assert pick_bool(False, No...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_stack.py
tests/test_stack.py
from rich._stack import Stack def test_stack(): stack = Stack() stack.push("foo") stack.push("bar") assert stack.top == "bar" assert stack.pop() == "bar" assert stack.top == "foo"
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_json.py
tests/test_json.py
from rich.json import JSON import datetime def test_print_json_data_with_default(): date = datetime.date(2021, 1, 1) json = JSON.from_data({"date": date}, default=lambda d: d.isoformat()) assert str(json.text) == '{\n "date": "2021-01-01"\n}'
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_tools.py
tests/test_tools.py
from rich._loop import loop_first, loop_last, loop_first_last from rich._ratio import ratio_distribute def test_loop_first(): assert list(loop_first([])) == [] iterable = loop_first(["apples", "oranges", "pears", "lemons"]) assert next(iterable) == (True, "apples") assert next(iterable) == (False, "or...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_inspect.py
tests/test_inspect.py
import io import sys from types import ModuleType from typing import Sequence, Type import pytest from rich import inspect from rich._inspect import ( get_object_types_mro, get_object_types_mro_as_strings, is_object_one_of_types, ) from rich.console import Console skip_py38 = pytest.mark.skipif( sys....
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_measure.py
tests/test_measure.py
from rich.text import Text import pytest from rich.errors import NotRenderableError from rich.console import Console from rich.measure import Measurement, measure_renderables def test_span(): measurement = Measurement(10, 100) assert measurement.span == 90 def test_no_renderable(): console = Console() ...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_markup.py
tests/test_markup.py
import pytest from rich.console import Console from rich.errors import MarkupError from rich.markup import RE_TAGS, Tag, _parse, escape, render from rich.text import Span, Text def test_re_no_match(): assert RE_TAGS.match("[True]") == None assert RE_TAGS.match("[False]") == None assert RE_TAGS.match("[No...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_spinner.py
tests/test_spinner.py
import pytest from rich.console import Console from rich.measure import Measurement from rich.rule import Rule from rich.spinner import Spinner from rich.text import Text def test_spinner_create(): Spinner("dots") with pytest.raises(KeyError): Spinner("foobar") def test_spinner_render(): time =...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_style.py
tests/test_style.py
import pytest from rich import errors from rich.color import Color, ColorSystem, ColorType from rich.style import Style, StyleStack def test_str(): assert str(Style(bold=False)) == "not bold" assert str(Style(color="red", bold=False)) == "not bold red" assert str(Style(color="red", bold=False, italic=Tru...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_tree.py
tests/test_tree.py
import sys import pytest from rich.console import Console from rich.measure import Measurement from rich.tree import Tree def test_render_single_node(): tree = Tree("foo") console = Console(color_system=None, width=20) console.begin_capture() console.print(tree) assert console.end_capture() == "...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_cells.py
tests/test_cells.py
import string from rich import cells from rich.cells import _is_single_cell_widths, chop_cells def test_cell_len_long_string(): # Long strings don't use cached cell length implementation assert cells.cell_len("abc" * 200) == 3 * 200 # Boundary case assert cells.cell_len("a" * 512) == 512 def test_c...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_containers.py
tests/test_containers.py
from rich.console import Console from rich.containers import Lines, Renderables from rich.text import Span, Text from rich.style import Style def test_renderables_measure(): console = Console() text = Text("foo") renderables = Renderables([text]) result = renderables.__rich_measure__(console, console...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_constrain.py
tests/test_constrain.py
from rich.console import Console from rich.constrain import Constrain from rich.text import Text def test_width_of_none(): console = Console() constrain = Constrain(Text("foo"), width=None) min_width, max_width = constrain.__rich_measure__( console, console.options.update_width(80) ) asser...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_prompt.py
tests/test_prompt.py
import io from rich.console import Console from rich.prompt import Confirm, IntPrompt, Prompt def test_prompt_str(): INPUT = "egg\nfoo" console = Console(file=io.StringIO()) name = Prompt.ask( "what is your name", console=console, choices=["foo", "bar"], default="baz", ...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_rule_in_table.py
tests/test_rule_in_table.py
import io from textwrap import dedent import pytest from rich import box from rich.console import Console from rich.rule import Rule from rich.table import Table @pytest.mark.parametrize("expand_kwarg", ({}, {"expand": False})) def test_rule_in_unexpanded_table(expand_kwarg): console = Console(width=32, file=io...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_live_render.py
tests/test_live_render.py
import pytest from rich.live_render import LiveRender from rich.console import Console, ConsoleDimensions, ConsoleOptions from rich.style import Style from rich.segment import Segment @pytest.fixture def live_render(): return LiveRender(renderable="my string") def test_renderable(live_render): assert live_r...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_columns.py
tests/test_columns.py
# encoding=utf-8 import io from rich.columns import Columns from rich.console import Console COLUMN_DATA = [ "Ursus americanus", "American buffalo", "Bison bison", "American crow", "Corvus brachyrhynchos", "American marten", "Martes americana", "American racer", "Coluber constrict...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_log.py
tests/test_log.py
# encoding=utf-8 import io import re from rich.console import Console re_link_ids = re.compile(r"id=[\d\.\-]*?;.*?\x1b") def replace_link_ids(render: str) -> str: """Link IDs have a random ID and system path which is a problem for reproducible tests. """ return re_link_ids.sub("id=0;foo\x1b", ren...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_table.py
tests/test_table.py
# encoding=utf-8 import io from textwrap import dedent import pytest from rich import box, errors from rich.console import Console from rich.measure import Measurement from rich.style import Style from rich.table import Column, Table from rich.text import Text def render_tables(): console = Console( wi...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/conftest.py
tests/conftest.py
import pytest @pytest.fixture(autouse=True) def reset_color_envvars(monkeypatch): """Remove color-related envvars to fix test output""" monkeypatch.delenv("FORCE_COLOR", raising=False) monkeypatch.delenv("NO_COLOR", raising=False)
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_markdown.py
tests/test_markdown.py
# coding=utf-8 MARKDOWN = """Heading ======= Sub-heading ----------- ### Heading #### H4 Heading ##### H5 Heading ###### H6 Heading Paragraphs are separated by a blank line. Two spaces at the end of a line produces a line break. Text attributes _italic_, **bold**, `monospace`. Horizontal rule: --- Bullet l...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_box.py
tests/test_box.py
import pytest from rich.console import ConsoleOptions, ConsoleDimensions from rich.box import ( ASCII, DOUBLE, ROUNDED, HEAVY, SQUARE, MINIMAL_HEAVY_HEAD, MINIMAL, SIMPLE_HEAVY, SIMPLE, HEAVY_EDGE, HEAVY_HEAD, ) def test_str(): assert str(ASCII) == "+--+\n| ||\n|-+|\n|...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_color_triplet.py
tests/test_color_triplet.py
from rich.color_triplet import ColorTriplet def test_hex(): assert ColorTriplet(255, 255, 255).hex == "#ffffff" assert ColorTriplet(0, 255, 0).hex == "#00ff00" def test_rgb(): assert ColorTriplet(255, 255, 255).rgb == "rgb(255,255,255)" assert ColorTriplet(0, 255, 0).rgb == "rgb(0,255,0)" def test...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_segment.py
tests/test_segment.py
from io import StringIO import pytest from rich.cells import cell_len from rich.segment import ControlType, Segment, SegmentLines, Segments from rich.style import Style def test_repr(): assert repr(Segment("foo")) == "Segment('foo')" home = (ControlType.HOME, 0) assert ( repr(Segment("foo", None...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_panel.py
tests/test_panel.py
import io import pytest from rich.console import Console from rich.panel import Panel from rich.segment import Segment from rich.style import Style from rich.text import Text tests = [ Panel("Hello, World", padding=0), Panel("Hello, World", expand=False, padding=0), Panel.fit("Hello, World", padding=0), ...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_text.py
tests/test_text.py
import re from io import StringIO from typing import List import pytest from rich.console import Console, Group from rich.measure import Measurement from rich.style import Style from rich.text import Span, Text def test_span(): span = Span(1, 10, "foo") repr(span) assert bool(span) assert not Span(1...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_bar.py
tests/test_bar.py
from rich.console import Console from rich.progress_bar import ProgressBar from rich.segment import Segment from rich.style import Style from .render import render def test_init(): bar = ProgressBar(completed=50) repr(bar) assert bar.percentage_completed == 50.0 def test_update(): bar = ProgressBar...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_padding.py
tests/test_padding.py
import pytest from rich.padding import Padding from rich.console import Console, ConsoleDimensions, ConsoleOptions from rich.style import Style from rich.segment import Segment def test_repr(): padding = Padding("foo", (1, 2)) assert isinstance(repr(padding), str) def test_indent(): indent_result = Pad...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_ansi.py
tests/test_ansi.py
import pytest from rich.ansi import AnsiDecoder from rich.console import Console from rich.style import Style from rich.text import Span, Text def test_decode(): console = Console( force_terminal=True, legacy_windows=False, color_system="truecolor" ) console.begin_capture() console.print("Hel...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/__init__.py
tests/__init__.py
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_repr.py
tests/test_repr.py
from typing import Optional import pytest import rich.repr from rich.console import Console from inspect import Parameter @rich.repr.auto class Foo: def __init__(self, foo: str, bar: Optional[int] = None, egg: int = 1): self.foo = foo self.bar = bar self.egg = egg def __rich_repr__...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_block_bar.py
tests/test_block_bar.py
from rich.bar import Bar from rich.console import Console from .render import render expected = [ "\x1b[39;49m ▐█████████████████████████ \x1b[0m\n", "\x1b[39;49m ██████████████████████▌ \x1b[0m\n", "\x1b[39;49m ...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_filesize.py
tests/test_filesize.py
from rich import filesize def test_traditional(): assert filesize.decimal(0) == "0 bytes" assert filesize.decimal(1) == "1 byte" assert filesize.decimal(2) == "2 bytes" assert filesize.decimal(1000) == "1.0 kB" assert filesize.decimal(1.5 * 1000 * 1000) == "1.5 MB" assert filesize.decimal(0, p...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_card.py
tests/test_card.py
import io import re from rich.__main__ import make_test_card from rich.console import Console, RenderableType from ._card_render import expected re_link_ids = re.compile(r"id=[\d\.\-]*?;.*?\x1b") def replace_link_ids(render: str) -> str: """Link IDs have a random ID and system path which is a problem for r...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_ratio.py
tests/test_ratio.py
import pytest from typing import NamedTuple, Optional from rich._ratio import ratio_reduce, ratio_resolve class Edge(NamedTuple): size: Optional[int] = None ratio: int = 1 minimum_size: int = 1 @pytest.mark.parametrize( "total,ratios,maximums,values,result", [ (20, [2, 4], [20, 20], [5,...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_styled.py
tests/test_styled.py
import io from rich.console import Console from rich.measure import Measurement from rich.styled import Styled def test_styled(): styled_foo = Styled("foo", "on red") console = Console(file=io.StringIO(), force_terminal=True, _environ={}) assert Measurement.get(console, console.options, styled_foo) == Me...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_getfileno.py
tests/test_getfileno.py
from rich._fileno import get_fileno def test_get_fileno(): class FileLike: def fileno(self) -> int: return 123 assert get_fileno(FileLike()) == 123 def test_get_fileno_missing(): class FileLike: pass assert get_fileno(FileLike()) is None def test_get_fileno_broken(): ...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_file_proxy.py
tests/test_file_proxy.py
import io import sys import pytest from rich.console import Console from rich.file_proxy import FileProxy def test_empty_bytes(): console = Console() file_proxy = FileProxy(console, sys.stdout) # File should raise TypeError when writing bytes with pytest.raises(TypeError): file_proxy.write(b...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_protocol.py
tests/test_protocol.py
import io from rich.abc import RichRenderable from rich.console import Console from rich.panel import Panel from rich.text import Text class Foo: def __rich__(self) -> Text: return Text("Foo") def test_rich_cast(): foo = Foo() console = Console(file=io.StringIO()) console.print(foo) ass...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_null_file.py
tests/test_null_file.py
from rich._null_file import NullFile def test_null_file(): file = NullFile() with file: assert file.write("abc") == 0 assert file.close() is None assert not file.isatty() assert file.read() == "" assert not file.readable() assert file.readline() == "" as...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_jupyter.py
tests/test_jupyter.py
from rich.console import Console def test_jupyter(): console = Console(force_jupyter=True) assert console.width == 115 assert console.height == 100 assert console.color_system == "truecolor" def test_jupyter_columns_env(): console = Console(_environ={"JUPYTER_COLUMNS": "314"}, force_jupyter=True...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_rule.py
tests/test_rule.py
import io import pytest from rich.console import Console from rich.rule import Rule from rich.text import Text def test_rule(): console = Console( width=16, file=io.StringIO(), force_terminal=True, legacy_windows=False, _environ={}, ) console.print(Rule()) con...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_emoji.py
tests/test_emoji.py
import pytest from rich.emoji import Emoji, NoEmoji from .render import render def test_no_emoji(): with pytest.raises(NoEmoji): Emoji("ambivalent_bunny") def test_str_repr(): assert str(Emoji("pile_of_poo")) == "💩" assert repr(Emoji("pile_of_poo")) == "<emoji 'pile_of_poo'>" def test_repla...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_win32_console.py
tests/test_win32_console.py
import dataclasses import sys from unittest import mock from unittest.mock import patch import pytest from rich.style import Style if sys.platform == "win32": from rich import _win32_console from rich._win32_console import COORD, LegacyWindowsTerm, WindowsCoordinates CURSOR_X = 1 CURSOR_Y = 2 CU...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_windows_renderer.py
tests/test_windows_renderer.py
import sys from unittest.mock import call, create_autospec import pytest try: from rich._win32_console import LegacyWindowsTerm, WindowsCoordinates from rich._windows_renderer import legacy_windows_render except: # These modules can only be imported on Windows pass from rich.segment import ControlType...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_palette.py
tests/test_palette.py
from rich._palettes import STANDARD_PALETTE from rich.table import Table def test_rich_cast(): table = STANDARD_PALETTE.__rich__() assert isinstance(table, Table) assert table.row_count == 16
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_align.py
tests/test_align.py
import io import pytest from rich.console import Console from rich.align import Align, VerticalCenter from rich.measure import Measurement def test_bad_align_legal(): # Legal Align("foo", "left") Align("foo", "center") Align("foo", "right") # illegal with pytest.raises(ValueError): ...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/_card_render.py
tests/_card_render.py
expected = "\x1b[3m Rich features \x1b[0m\n\x1b[1;31m \x1b[0m \n\x1b[1;31m \x1b[0m\x1b[1;31m Colors \x1b[0m\x1b[1;31m \x1b[0m✓ \x1b[1...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/tests/test_console.py
tests/test_console.py
import datetime import io import os import subprocess import sys import tempfile from typing import Optional, Tuple, Type, Union from unittest import mock import pytest from rich import errors from rich._null_file import NullFile from rich.color import ColorSystem from rich.console import ( CaptureError, Cons...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
true
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/docs/source/conf.py
docs/source/conf.py
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/columns.py
examples/columns.py
""" This example shows how to display content in columns. The data is pulled from https://randomuser.me """ import json from urllib.request import urlopen from rich.console import Console from rich.columns import Columns from rich.panel import Panel def get_content(user): """Extract text from user dict.""" ...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/rainbow.py
examples/rainbow.py
""" This example demonstrates how to write a custom highlighter. """ from random import randint from rich import print from rich.highlighter import Highlighter class RainbowHighlighter(Highlighter): def highlight(self, text): for index in range(len(text)): text.stylize(f"color({randint(16,...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/justify2.py
examples/justify2.py
""" This example demonstrates the justify argument to print. """ from rich.console import Console from rich.panel import Panel console = Console(width=20) style = "bold white on blue" panel = Panel("Rich", style="on red", expand=False) console.print(panel, style=style) console.print(panel, style=style, justify="left...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false
Textualize/rich
https://github.com/Textualize/rich/blob/53757bc234cf18977cade41a5b64f3abaccb0b85/examples/save_table_svg.py
examples/save_table_svg.py
""" Demonstrates how to export a SVG """ from rich.console import Console from rich.table import Table table = Table(title="Star Wars Movies") table.add_column("Released", style="cyan", no_wrap=True) table.add_column("Title", style="magenta") table.add_column("Box Office", justify="right", style="green") table.add_...
python
MIT
53757bc234cf18977cade41a5b64f3abaccb0b85
2026-01-04T14:39:17.105051Z
false