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 💩"