Skip to content

Commit

Permalink
Add test for RST replace
Browse files Browse the repository at this point in the history
  • Loading branch information
KeyWeeUsr authored and tshirtman committed May 21, 2018
1 parent e658c65 commit c9ecb40
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions kivy/tests/test_rst_replace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# coding=utf-8
from kivy.tests.common import GraphicUnitTest
from kivy.uix.rst import RstDocument


class TestRstReplace(RstDocument):
def __init__(self, **kwargs):
super(TestRstReplace, self).__init__(**kwargs)
self.text = '''
.. |uni| unicode:: 0xe4
.. |nbsp| unicode:: 0xA0
.. |text| replace:: is
.. |hop| replace:: replaced
.. _hop: https://kivy.org
|uni| |nbsp| |text| |hop|_
'''


class RstSubstitutionTestCase(GraphicUnitTest):
def test_rst_replace(self):
rst = TestRstReplace()
self.render(rst)

# RstDocument > Scatter > GridLayout > RstParagraph
pg = rst.children[0].children[0].children[0]
rendered_text = pg.text[:]

# [anchor=] and [ref=] might change in the future
compare_text = (
u'[color=202020ff][anchor=hop]'
u'ä   is '
u'[ref=None][color=ce5c00ff]replaced[/color][/ref]'
u'[/color]'
)
self.assertEqual(rendered_text, compare_text)


if __name__ == '__main__':
import unittest
unittest.main()

0 comments on commit c9ecb40

Please sign in to comment.