mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add tests for abbr_role. Refs #949
This commit is contained in:
parent
17c551c793
commit
99e734cb71
1 changed files with 32 additions and 0 deletions
32
pelican/tests/test_rstdirectives.py
Normal file
32
pelican/tests/test_rstdirectives.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals, print_function
|
||||
|
||||
from mock import Mock
|
||||
from pelican.tests.support import unittest
|
||||
|
||||
class Test_abbr_role(unittest.TestCase):
|
||||
def call_it(self, text):
|
||||
from pelican.rstdirectives import abbr_role
|
||||
rawtext = text
|
||||
lineno = 42
|
||||
inliner = Mock(name='inliner')
|
||||
nodes, system_messages = abbr_role(
|
||||
'abbr', rawtext, text, lineno, inliner)
|
||||
self.assertEqual(system_messages, [])
|
||||
self.assertEqual(len(nodes), 1)
|
||||
return nodes[0]
|
||||
|
||||
def test(self):
|
||||
node = self.call_it("Abbr (Abbreviation)")
|
||||
self.assertEqual(node.astext(), "Abbr")
|
||||
self.assertEqual(node['explanation'], "Abbreviation")
|
||||
|
||||
def test_newlines_in_explanation(self):
|
||||
node = self.call_it("CUL (See you\nlater)")
|
||||
self.assertEqual(node.astext(), "CUL")
|
||||
self.assertEqual(node['explanation'], "See you\nlater")
|
||||
|
||||
def test_newlines_in_abbr(self):
|
||||
node = self.call_it("US of\nA \n (USA)")
|
||||
self.assertEqual(node.astext(), "US of\nA")
|
||||
self.assertEqual(node['explanation'], "USA")
|
||||
Loading…
Add table
Add a link
Reference in a new issue