MCPcopy Index your code
hub / github.com/Python-Markdown/markdown / assertMarkdownRenders

Method assertMarkdownRenders

markdown/test_tools.py:61–79  ·  view source on GitHub ↗

Test that source Markdown text renders to expected output with given keywords. `expected_attrs` accepts a `dict`. Each key should be the name of an attribute on the `Markdown` instance and the value should be the expected value after the source text is parsed by Mar

(self, source, expected, expected_attrs=None, **kwargs)

Source from the content-addressed store, hash-verified

59 """ Default options to pass to Markdown for each test. """
60
61 def assertMarkdownRenders(self, source, expected, expected_attrs=None, **kwargs):
62 """
63 Test that source Markdown text renders to expected output with given keywords.
64
65 `expected_attrs` accepts a `dict`. Each key should be the name of an attribute
66 on the `Markdown` instance and the value should be the expected value after
67 the source text is parsed by Markdown. After the expected output is tested,
68 the expected value for each attribute is compared against the actual
69 attribute of the `Markdown` instance using `TestCase.assertEqual`.
70 """
71
72 expected_attrs = expected_attrs or {}
73 kws = self.default_kwargs.copy()
74 kws.update(kwargs)
75 md = Markdown(**kws)
76 output = md.convert(source)
77 self.assertMultiLineEqual(output, expected)
78 for key, value in expected_attrs.items():
79 self.assertEqual(getattr(md, key), value)
80
81 def dedent(self, text):
82 """

Callers 15

test_raw_paragraphMethod · 0.80
test_raw_spanMethod · 0.80
test_code_spanMethod · 0.80
test_raw_emptyMethod · 0.80
test_raw_empty_spaceMethod · 0.80

Calls 2

convertMethod · 0.95
MarkdownClass · 0.90

Tested by

no test coverage detected