Add tests

This commit is contained in:
Daniel Fancsali 2019-10-07 23:56:09 +02:00
commit 24ebf2c2f6
3 changed files with 75 additions and 0 deletions

View file

@ -0,0 +1,3 @@
Title: One -, two --, three --- dashes!
One: -; Two: --; Three: ---

View file

@ -0,0 +1,4 @@
One -, two --, three --- dashes!
################################
One: -; Two: --; Three: ---

View file

@ -416,6 +416,40 @@ class RstReaderTest(ReaderTest):
with six.assertRaisesRegex(self, Exception, "underline too short"): with six.assertRaisesRegex(self, Exception, "underline too short"):
self.read_file(path='../parse_error/parse_error.rst') self.read_file(path='../parse_error/parse_error.rst')
def test_typogrify_dashes_config(self):
# Test default config
page = self.read_file(
path = 'article_with_typogrify_dashes.rst',
TYPOGRIFY = True,
TYPOGRIFY_DASHES = 'default')
expected = "<p>One: -; Two: &#8212;; Three:&nbsp;&#8212;-</p>\n"
expected_title = "One -, two &#8212;, three &#8212;-&nbsp;dashes!"
self.assertEqual(page.content, expected)
self.assertEqual(page.title, expected_title)
# Test 'oldschool' variant
page = self.read_file(
path = 'article_with_typogrify_dashes.rst',
TYPOGRIFY = True,
TYPOGRIFY_DASHES = 'oldschool')
expected = "<p>One: -; Two: &#8211;; Three:&nbsp;&#8212;</p>\n"
expected_title = "One -, two &#8211;, three &#8212;&nbsp;dashes!"
self.assertEqual(page.content, expected)
self.assertEqual(page.title, expected_title)
# Test 'oldschool_inverted' variant
page = self.read_file(
path = 'article_with_typogrify_dashes.rst',
TYPOGRIFY = True,
TYPOGRIFY_DASHES = 'oldschool_inverted')
expected = "<p>One: -; Two: &#8212;; Three:&nbsp;&#8211;</p>\n"
expected_title = "One -, two &#8212;, three &#8211;&nbsp;dashes!"
self.assertEqual(page.content, expected)
self.assertEqual(page.title, expected_title)
@unittest.skipUnless(readers.Markdown, "markdown isn't installed") @unittest.skipUnless(readers.Markdown, "markdown isn't installed")
class MdReaderTest(ReaderTest): class MdReaderTest(ReaderTest):
@ -631,6 +665,40 @@ class MdReaderTest(ReaderTest):
self.assertEqual(metadata, {}) self.assertEqual(metadata, {})
self.assertEqual(content, '') self.assertEqual(content, '')
def test_typogrify_dashes_config(self):
# Test default config
page = self.read_file(
path = 'article_with_typogrify_dashes.md',
TYPOGRIFY = True,
TYPOGRIFY_DASHES = 'default')
expected = "<p>One: -; Two: &#8212;; Three:&nbsp;&#8212;-</p>"
expected_title = "One -, two &#8212;, three &#8212;-&nbsp;dashes!"
self.assertEqual(page.content, expected)
self.assertEqual(page.title, expected_title)
# Test 'oldschool' variant
page = self.read_file(
path = 'article_with_typogrify_dashes.md',
TYPOGRIFY = True,
TYPOGRIFY_DASHES = 'oldschool')
expected = "<p>One: -; Two: &#8211;; Three:&nbsp;&#8212;</p>"
expected_title = "One -, two &#8211;, three &#8212;&nbsp;dashes!"
self.assertEqual(page.content, expected)
self.assertEqual(page.title, expected_title)
# Test 'oldschool_inverted' variant
page = self.read_file(
path = 'article_with_typogrify_dashes.md',
TYPOGRIFY = True,
TYPOGRIFY_DASHES = 'oldschool_inverted')
expected = "<p>One: -; Two: &#8212;; Three:&nbsp;&#8211;</p>"
expected_title = "One -, two &#8212;, three &#8211;&nbsp;dashes!"
self.assertEqual(page.content, expected)
self.assertEqual(page.title, expected_title)
class HTMLReaderTest(ReaderTest): class HTMLReaderTest(ReaderTest):
def test_article_with_comments(self): def test_article_with_comments(self):