From 1c543b746d821ed836e9ab44c1f87a8270dcc37a Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Sat, 11 Dec 2021 16:41:19 +0000 Subject: [PATCH] tests for markup property --- CHANGELOG.md | 6 +++++- tests/test_text.py | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3afff1b4..55aa0c8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Double print of progress bar in Jupyter +- Double print of progress bar in Jupyter https://github.com/willmcgugan/rich/issues/1737 + +### Added + +- Added Text.markup property https://github.com/willmcgugan/rich/issues/1751 ## [10.15.2] - 2021-12-02 diff --git a/tests/test_text.py b/tests/test_text.py index 63f128e5..d1d721bd 100644 --- a/tests/test_text.py +++ b/tests/test_text.py @@ -715,3 +715,19 @@ def test_on(): assert text.get_style_at_offset(console, 0).meta == expected assert text.get_style_at_offset(console, 1).meta == expected assert text.get_style_at_offset(console, 2).meta == expected + + +def test_markup_property(): + assert Text("").markup == "" + assert Text("foo").markup == "foo" + assert Text("foo", style="bold").markup == "[bold]foo[/bold]" + assert Text.from_markup("foo [red]bar[/red]").markup == "foo [red]bar[/red]" + assert ( + Text.from_markup("foo [red]bar[/red]", style="bold").markup + == "[bold]foo [red]bar[/red][/bold]" + ) + assert ( + Text.from_markup("[bold]foo [italic]bar[/bold] baz[/italic]").markup + == "[bold]foo [italic]bar[/bold] baz[/italic]" + ) + assert Text("[bold]foo").markup == "\\[bold]foo"