From a3f3bcff68ee6bd9ba74b8d4810febc3f431ba20 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Wed, 11 Dec 2019 19:03:55 +0000 Subject: [PATCH] emoji tests --- rich/emoji.py | 2 +- rich/markdown.py | 2 +- tests/test_emoji.py | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 tests/test_emoji.py diff --git a/rich/emoji.py b/rich/emoji.py index 8441f28e..4ad68857 100644 --- a/rich/emoji.py +++ b/rich/emoji.py @@ -56,7 +56,7 @@ class Emoji: yield Segment(self._char, console.get_style(self.style)) -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover from .console import Console c = Console(markup=None) diff --git a/rich/markdown.py b/rich/markdown.py index 5cc5e825..9455d72f 100644 --- a/rich/markdown.py +++ b/rich/markdown.py @@ -482,7 +482,7 @@ This is a [link](https://www.willmcgugan.com) # """ -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover from .console import Console console = Console(record=True) diff --git a/tests/test_emoji.py b/tests/test_emoji.py new file mode 100644 index 00000000..202ad316 --- /dev/null +++ b/tests/test_emoji.py @@ -0,0 +1,17 @@ +import pytest + +from rich.emoji import Emoji, NoEmoji + + +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")) == "" + + +def test_replace(): + assert Emoji.replace("my code is :pile_of_poo:") == "my code is 💩"