Permalink
Checking mergeability…
Don’t worry, you can still create the pull request.
Comparing changes
Open a pull request
- 1 commit
- 11 files changed
- 0 commit comments
- 1 contributor
Unified
Split
Showing
with
271 additions
and 0 deletions.
- +16 −0 .travis.yml
- +79 −0 tests.py
- 0 tests/__init__.py
- +26 −0 tests/with_both_options.py
- +26 −0 tests/with_emoji_overrides_option.py
- +24 −0 tests/with_mdx_unimoji_extension.py
- +18 −0 tests/with_span_class_option.py
- +18 −0 tests/with_span_class_option_none.py
- +22 −0 tests/with_styles_overrides_option.py
- +17 −0 tests/without_mdx_unimoji_extension.py
- +25 −0 tox.ini
| @@ -0,0 +1,16 @@ | |||
| language: python | |||
| python: | |||
| - "2.7" | |||
| - "3.3" | |||
| - "3.4" | |||
| - "3.5" | |||
| install: | |||
| - pip install -q Markdown | |||
| script: | |||
| - PYTHONPATH=. python tests/without_mdx_unimoji_extension.py | |||
| - PYTHONPATH=. python tests/with_mdx_unimoji_extension.py | |||
| - PYTHONPATH=. python tests/with_emoji_overrides_option.py | |||
| - PYTHONPATH=. python tests/with_styles_overrides_option.py | |||
| - PYTHONPATH=. python tests/with_span_class_option.py | |||
| - PYTHONPATH=. python tests/with_span_class_option_none.py | |||
| - PYTHONPATH=. python tests/with_both_options.py | |||
| @@ -0,0 +1,79 @@ | |||
| # coding: utf-8 | |||
| from __future__ import unicode_literals | |||
|
|
|||
| from unittest import main, TestCase | |||
| from markdown import markdown | |||
| from mdx_unimoji import UnimojiExtension | |||
|
|
|||
|
|
|||
| class Test(TestCase): | |||
| def test_markdown_without_emoji_extension(self): | |||
| text = 'I <3 you! Just kidding. :P' | |||
| should_be = '<p>I <3 you! Just kidding. :P</p>' | |||
| result = markdown(text, extensions=[]) | |||
| self.assertEqual(should_be, result) | |||
|
|
|||
| def test_without_emojis(self): | |||
| text = 'I love you! Just kidding. *smile*' | |||
| should_be = '<p>I love you! Just kidding. <em>smile</em></p>' | |||
| result = markdown(text, extensions=[]) | |||
| self.assertEqual(should_be, result) | |||
|
|
|||
| def test_with_emojis(self): | |||
| text = 'I <3 you! Just kidding. :P' | |||
| # should_be = '<p>I <span class="emoji" style="color:red">❤</span> you! Just kidding. <span class="emoji">😛</span></p>' | |||
| should_be = '<p>I ❤ you! Just kidding. 😛</p>' | |||
| result = markdown(text, extensions=['mdx_unimoji']) | |||
| self.assertEqual(should_be, result) | |||
|
|
|||
| def test_mdx_overrides_emoji_option(self): | |||
| img_heart = '<img alt="love" src="heart.png"/>' | |||
| img_tongue = '<img alt=":P" src="tongue.png"/>' | |||
| overrides = UnimojiExtension.EMOJI | |||
| overrides.update({ | |||
| img_heart: ['<3'], | |||
| img_tongue: ':p :P :-p :-P'.split(), | |||
| }) | |||
| text = 'I <3 you! Just kidding. :P' | |||
| should_be = '<p>I <img alt="love" class="emoji" src="heart.png" /> you! Just kidding. <img alt=":P" class="emoji" src="tongue.png" /></p>' | |||
| result = markdown(text, extensions=[UnimojiExtension(emoji=overrides)]) | |||
| self.assertEqual(should_be, result) | |||
|
|
|||
| def test_mdx_overrides_emoji_option(self): | |||
| overrides = UnimojiExtension.STYLES | |||
| overrides.update({ | |||
| '❤': 'color:blue', | |||
| }) | |||
| text = 'I <3 you! Just kidding. :P' | |||
| should_be = '<p>I <span class="emoji" style="color:blue">❤</span> you! Just kidding. <span class="emoji">😛</span></p>' | |||
| result = markdown(text, extensions=[UnimojiExtension(styles=overrides)]) | |||
| self.assertEqual(should_be, result) | |||
|
|
|||
| def test_mdx_span_class_option(self): | |||
| text = 'I <3 you! Just kidding. :P' | |||
| should_be = '<p>I <span class="other" style="color:red">❤</span> you! Just kidding. <span class="other">😛</span></p>' | |||
| result = markdown(text, extensions=[UnimojiExtension(span_class='other')]) | |||
| self.assertEqual(should_be, result) | |||
|
|
|||
| def test_mdx_span_class_none_option(self): | |||
|
|
|||
| text = 'I <3 you! Just kidding. :P' | |||
| should_be = '<p>I ❤ you! Just kidding. 😛</p>' | |||
| result = markdown(text, extensions=[UnimojiExtension(span_class=None)]) | |||
| self.assertEqual(should_be, result) | |||
|
|
|||
| # def test_mdx_both_options(self): | |||
| # img_heart = '<img alt="love" src="heart.png"/>' | |||
| # img_tongue = '<img alt=":P" src="tongue.png"/>' | |||
| # overrides = UnimojiExtension.EMOJI | |||
| # overrides.update({img_heart: ['<3'], | |||
| # img_tongue: ':p :P :-p :-P'.split()}) | |||
| # text = 'I <3 you! Just kidding. :P' | |||
| # should_be = '<p>I <img alt="love" class="other" src="heart.png" /> you! Just kidding. <span class="other">😛</span></p>' | |||
| # result = markdown(text, | |||
| # extensions=[UnimojiExtension(span_class='other', | |||
| # emoji=overrides)]) | |||
| # self.assertEqual(should_be, result) | |||
|
|
|||
| if __name__ == '__main__': | |||
| main() | |||
No changes.
| @@ -0,0 +1,26 @@ | |||
| # coding: utf-8 | |||
| from __future__ import unicode_literals | |||
|
|
|||
| from unittest import main, TestCase | |||
|
|
|||
| from markdown import markdown | |||
| from mdx_unimoji import UnimojiExtension | |||
|
|
|||
|
|
|||
| class Test(TestCase): | |||
| def test_mdx_both_options(self): | |||
| img_cake = '<img alt="cake" src="cake.png"/>' | |||
| img_wink = '<img alt="wink" src="wink.png"/>' | |||
| overrides = UnimojiExtension.EMOJI | |||
| overrides.update({img_cake: ['<3'], | |||
| img_wink: ';-) ;] ;-]'.split()}) | |||
| text = 'This was a triumph. The :cake: is a lie. ;)' | |||
| # should_be = '<p>This was a triumph. The <img alt="cake" class="other" src="cake.png"> is a lie. <img alt="wink" class="other" src="wink.png"/></p>' | |||
| should_be = '<p>This was a triumph. The <span class="other" style="color:maroon">🍰</span> is a lie. <span class="other">😉</span></p>' | |||
| result = markdown(text, | |||
| extensions=[UnimojiExtension(span_class='other', | |||
| emoji=overrides)]) | |||
| self.assertEqual(should_be, result) | |||
|
|
|||
| if __name__ == '__main__': | |||
| main() | |||
| @@ -0,0 +1,26 @@ | |||
| # coding: utf-8 | |||
| from __future__ import unicode_literals | |||
|
|
|||
| from unittest import main, TestCase | |||
|
|
|||
| from markdown import markdown | |||
| from mdx_unimoji import UnimojiExtension | |||
|
|
|||
|
|
|||
| class Test(TestCase): | |||
| def test_mdx_overrides_emoji_option(self): | |||
| img_cake = '<img alt="cake" src="cake.png"/>' | |||
| img_wink = '<img alt="wink" src="wink.png"/>' | |||
| overrides = UnimojiExtension.EMOJI | |||
| overrides.update({ | |||
| img_cake: [':cake:'], | |||
| img_wink: ';) ;-) ;] ;-]'.split(), | |||
|
|
|||
| }) | |||
| text = 'This was a triumph. The :cake: is a lie. ;)' | |||
| should_be = '<p>This was a triumph. The <img alt="cake" class="emoji" src="cake.png" /> is a lie. <img alt="wink" class="emoji" src="wink.png" /></p>' | |||
| result = markdown(text, extensions=[UnimojiExtension(emoji=overrides)]) | |||
| self.assertEqual(should_be, result) | |||
|
|
|||
| if __name__ == '__main__': | |||
| main() | |||
| @@ -0,0 +1,24 @@ | |||
| # coding: utf-8 | |||
| from __future__ import unicode_literals | |||
|
|
|||
| from unittest import main, TestCase | |||
|
|
|||
| from markdown import markdown | |||
| from mdx_unimoji import UnimojiExtension | |||
|
|
|||
|
|
|||
| class Test(TestCase): | |||
| def test_without_emojis(self): | |||
| text = 'This was a triumph. The *cake* is a lie.' | |||
| should_be = '<p>This was a triumph. The <em>cake</em> is a lie.</p>' | |||
| result = markdown(text, extensions=[]) | |||
| self.assertEqual(should_be, result) | |||
|
|
|||
| def test_with_emojis(self): | |||
| text = 'This was a triumph. The :cake: is a lie. ;)' | |||
| should_be = '<p>This was a triumph. The <span class="emoji" style="color:maroon">🍰</span> is a lie. <span class="emoji">😉</span></p>' | |||
| result = markdown(text, extensions=[UnimojiExtension()]) | |||
| self.assertEqual(should_be, result) | |||
|
|
|||
| if __name__ == '__main__': | |||
| main() | |||
| @@ -0,0 +1,18 @@ | |||
| # coding: utf-8 | |||
| from __future__ import unicode_literals | |||
|
|
|||
| from unittest import main, TestCase | |||
|
|
|||
| from markdown import markdown | |||
| from mdx_unimoji import UnimojiExtension | |||
|
|
|||
|
|
|||
| class Test(TestCase): | |||
| def test_mdx_span_class_option(self): | |||
| text = 'This was a triumph. The :cake: is a lie. ;)' | |||
| should_be = '<p>This was a triumph. The <span class="other" style="color:maroon">🍰</span> is a lie. <span class="other">😉</span></p>' | |||
| result = markdown(text, extensions=[UnimojiExtension(span_class='other')]) | |||
| self.assertEqual(should_be, result) | |||
|
|
|||
| if __name__ == '__main__': | |||
| main() | |||
| @@ -0,0 +1,18 @@ | |||
| # coding: utf-8 | |||
| from __future__ import unicode_literals | |||
|
|
|||
| from unittest import main, TestCase | |||
|
|
|||
| from markdown import markdown | |||
| from mdx_unimoji import UnimojiExtension | |||
|
|
|||
|
|
|||
| class Test(TestCase): | |||
| def test_mdx_span_class_none_option(self): | |||
| text = 'This was a triumph. The :cake: is a lie. ;)' | |||
| should_be = '<p>This was a triumph. The 🍰 is a lie. 😉</p>' | |||
| result = markdown(text, extensions=[UnimojiExtension(span_class=None)]) | |||
| self.assertEqual(should_be, result) | |||
|
|
|||
| if __name__ == '__main__': | |||
| main() | |||
| @@ -0,0 +1,22 @@ | |||
| # coding: utf-8 | |||
| from __future__ import unicode_literals | |||
|
|
|||
| from unittest import main, TestCase | |||
|
|
|||
| from markdown import markdown | |||
| from mdx_unimoji import UnimojiExtension | |||
|
|
|||
|
|
|||
| class Test(TestCase): | |||
| def test_mdx_overrides_emoji_option(self): | |||
| overrides = UnimojiExtension.STYLES | |||
| overrides.update({ | |||
| '🍰': 'color:blue', | |||
| }) | |||
| text = 'This was a triumph. The :cake: is a lie. ;)' | |||
| should_be = '<p>This was a triumph. The <span class="emoji" style="color:blue">🍰</span> is a lie. <span class="emoji">😉</span></p>' | |||
| result = markdown(text, extensions=[UnimojiExtension(styles=overrides)]) | |||
| self.assertEqual(should_be, result) | |||
|
|
|||
| if __name__ == '__main__': | |||
| main() | |||
| @@ -0,0 +1,17 @@ | |||
| # coding: utf-8 | |||
| from __future__ import unicode_literals | |||
|
|
|||
| from unittest import main, TestCase | |||
|
|
|||
| from markdown import markdown | |||
|
|
|||
|
|
|||
| class Test(TestCase): | |||
| def test_markdown_without_emoji_extension(self): | |||
| text = 'This was a triumph. The :cake: is a lie. ;)' | |||
| should_be = '<p>This was a triumph. The :cake: is a lie. ;)</p>' | |||
| result = markdown(text, extensions=[]) | |||
| self.assertEqual(should_be, result) | |||
|
|
|||
| if __name__ == '__main__': | |||
| main() | |||
| @@ -0,0 +1,25 @@ | |||
| [tox] | |||
| envlist = py27, py33, py34, py35 | |||
|
|
|||
| [testenv] | |||
| commands=\ | |||
| python tests/without_mdx_unimoji_extension.py \ | |||
| python tests/with_mdx_unimoji_extension.py \ | |||
| python tests/with_emoji_overrides_option.py \ | |||
| python tests/with_styles_overrides_option.py \ | |||
| python tests/with_span_class_option.py \ | |||
| python tests/with_span_class_option_none.py \ | |||
| python tests/with_both_options.py | |||
| setenv=PYTHONPATH=. | |||
|
|
|||
| [testenv:py27] | |||
| basepython = python2.7 | |||
|
|
|||
| [testenv:py33] | |||
| basepython = python3.3 | |||
|
|
|||
| [testenv:py34] | |||
| basepython = python3.4 | |||
|
|
|||
| [testenv:py35] | |||
| basepython = python3.5 | |||