def test_repformat(): """Make sure that pformat won't mutate self.""" s = '{{a|{{b|{{c}}}}}}' a, b, c = WikiText(s).templates assert '{{a\n | 1 = {{b\n | 1 = {{c}}\n }}\n}}' == a.pformat() # Again: assert '{{a\n | 1 = {{b\n | 1 = {{c}}\n }}\n}}' == a.pformat()
def test_repformat(self): """Make sure that pformat won't mutate self.""" ae = self.assertEqual s = '{{a|{{b|{{c}}}}}}' a, b, c = WikiText(s).templates ae('{{a\n | 1 = {{b\n | 1 = {{c}}\n }}\n}}', a.pformat()) # Again: ae('{{a\n | 1 = {{b\n | 1 = {{c}}\n }}\n}}', a.pformat())
def test_first_arg_of_tag_is_whitespace_sensitive(self): """The second argument of #tag is an exception. See the last warning on [[mw:Help:Magic_words#Miscellaneous]]: You must write {{#tag:tagname||attribute1=value1|attribute2=value2}} to pass an empty content. No space is permitted in the area reserved for content between the pipe characters || before attribute1. """ s = '{{#tag:ref||name="n1"}}' wt = WikiText(s) self.assertEqual(s, wt.pformat()) s = '{{#tag:foo| }}' wt = WikiText(s) self.assertEqual(s, wt.pformat())
def test_double_space_indent(self): s = "{{a|b=b|c=c|d=d|e=e}}" wt = WikiText(s) self.assertEqual( '{{a\n | b = b\n | c = c\n | d = d\n | e = e\n}}', wt.pformat(' '), )
def test_invoke(self): """#invoke args are also whitespace-sensitive.""" s = '{{#invoke:module|func|arg}}' wt = WikiText(s) self.assertEqual(s, wt.pformat())
def test_template_with_multi_args(self): wt = WikiText('{{a|b=b|c=c|d=d|e=e}}') self.assertEqual( '{{a\n | b = b\n | c = c\n | d = d\n | e = e\n}}', wt.pformat(), )
def test_invoke(): """#invoke args are also whitespace-sensitive.""" s = '{{#invoke:module|func|arg}}' wt = WikiText(s) assert s == wt.pformat()
def test_double_space_indent(): s = "{{a|b=b|c=c|d=d|e=e}}" wt = WikiText(s) assert '{{a\n | b = b\n | c = c\n | d = d\n | e = e\n}}' == \ wt.pformat(' ')
def test_template_with_multi_args(): wt = WikiText('{{a|b=b|c=c|d=d|e=e}}') assert '{{a\n | b = b\n | c = c\n | d = d\n | e = e\n}}' == \ wt.pformat()