import unittest
from markdown import parse
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.4.0
class MarkdownTest(unittest.TestCase):
def test_paragraph(self):
self.assertEqual(parse('This will be a paragraph'),
'
This will be a paragraph
')
def test_italics(self):
self.assertEqual(parse('_This will be italic_'),
'This will be italic
')
def test_bold(self):
self.assertEqual(parse('__This will be bold__'),
'This will be bold
')
def test_mixed_normal_italics_and_bold(self):
self.assertEqual(parse('This will _be_ __mixed__'),
'This will be mixed
')
def test_h1(self):
self.assertEqual(parse('# This will be an h1'),
'This will be an h1
')
def test_h2(self):
self.assertEqual(parse('## This will be an h2'),
'This will be an h2
')
def test_h6(self):
self.assertEqual(parse(
'###### This will be an h6'), 'This will be an h6
')
def test_unordered_lists(self):
self.assertEqual(parse('* Item 1\n* Item 2'),
'')
def test_little_bit_of_everything(self):
self.assertEqual(parse(
'# Header!\n* __Bold Item__\n* _Italic Item_'),
'Header!
')
def test_symbols_in_the_header_text_that_should_not_be_interpreted(self):
self.assertEqual(
parse('# This is a header with # and * in the text'),
'This is a header with # and * in the text
')
def test_symbols_in_the_list_item_text_that_should_not_be_interpreted(
self):
self.assertEqual(
parse(
'* Item 1 with a # in the text\n* Item 2 with * in the text'),
'- Item 1 with a # in the text
'
'- Item 2 with * in the text
')
def test_symbols_in_the_paragraph_text_that_should_not_be_interpreted(
self):
self.assertEqual(
parse('This is a paragraph with # and * in the text'),
'This is a paragraph with # and * in the text
')
def test_unordered_lists_close_properly_with_preceding_and_following_lines(
self):
self.assertEqual(
parse('# Start a list\n* Item 1\n* Item 2\nEnd a list'),
'Start a list
End a list
')
if __name__ == '__main__':
unittest.main()