1
0
Fork 0
forked from github/pelican
pelican-theme/pelican/tests/test_rstdirectives.py

41 lines
1.3 KiB
Python
Raw Normal View History

2014-10-16 06:56:43 -07:00
# -*- coding: utf-8 -*-
2015-06-16 09:25:09 +02:00
from __future__ import print_function, unicode_literals
from pelican.tests.support import unittest
try:
from unittest.mock import Mock
except ImportError:
try:
from mock import Mock
except ImportError:
Mock = False
2015-06-16 09:25:09 +02:00
2014-10-16 06:56:43 -07:00
@unittest.skipUnless(Mock, 'Needs Mock module')
2014-10-16 06:56:43 -07:00
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")