mirror of
https://github.com/Textualize/rich.git
synced 2025-08-03 17:48:25 +00:00
replace is_control with list of control codes
This commit is contained in:
parent
6f972a059a
commit
a998f23084
14 changed files with 188 additions and 156 deletions
|
@ -1,10 +1,15 @@
|
|||
from rich.segment import ControlCode, ControlType
|
||||
from rich.segment import Segment
|
||||
from rich.style import Style
|
||||
|
||||
|
||||
def test_repr():
|
||||
assert repr(Segment("foo")) == "Segment('foo', None)"
|
||||
assert repr(Segment.control("foo")) == "Segment.control('foo', None)"
|
||||
home = (ControlType.HOME, 0)
|
||||
assert (
|
||||
repr(Segment("foo", None, [home]))
|
||||
== "Segment('foo', None, [(<ControlType.HOME: 3>, 0)])"
|
||||
)
|
||||
|
||||
|
||||
def test_line():
|
||||
|
@ -81,10 +86,11 @@ def test_simplify():
|
|||
|
||||
|
||||
def test_filter_control():
|
||||
segments = [Segment("foo"), Segment("bar", is_control=True)]
|
||||
control_code = (ControlType.HOME, 0)
|
||||
segments = [Segment("foo"), Segment("bar", None, (control_code,))]
|
||||
assert list(Segment.filter_control(segments)) == [Segment("foo")]
|
||||
assert list(Segment.filter_control(segments, is_control=True)) == [
|
||||
Segment("bar", is_control=True)
|
||||
Segment("bar", None, (control_code,))
|
||||
]
|
||||
|
||||
|
||||
|
@ -107,11 +113,3 @@ def test_remove_color():
|
|||
Segment("foo", Style(bold=True)),
|
||||
Segment("bar", None),
|
||||
]
|
||||
|
||||
|
||||
def test_make_control():
|
||||
segments = [Segment("foo"), Segment("bar")]
|
||||
assert Segment.make_control(segments) == [
|
||||
Segment.control("foo"),
|
||||
Segment.control("bar"),
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue