def test_ast_directive(self): data = fixtures.load_json('directive.json') md = Markdown(renderer=AstRenderer()) md.use(PluginDirective()) # Use JSON to fix the differences between tuple and list tokens = json.loads(json.dumps(md(data['text']))) self.assertEqual(tokens, data['tokens'])
def test_ast_admonition(self): data = fixtures.load_json('admonition.json') md = create_markdown( renderer='ast', plugins=[Admonition()] ) # Use JSON to fix the differences between tuple and list tokens = json.loads(json.dumps(md(data['text']))) self.assertEqual(tokens, data['tokens'])
def load_fixtures(cls, case_file): cases = fixtures.load_json(case_file) def attach_case(n, data): def method(self): tokens = mistune.markdown(data['text'], renderer='ast') self.assertEqual(tokens, data['tokens']) name = 'test_{}'.format(n) method.__name__ = name method.__doc__ = 'Run fixture {} - {}'.format(case_file, n) setattr(cls, name, method) for n, data in enumerate(cases): attach_case(n, data)
def load_fixtures(cls, case_file): cases = fixtures.load_json(case_file) def attach_case(n, data): def method(self): tokens = mistune.markdown(data["text"], renderer="ast") print(tokens) self.assertEqual(tokens, data["tokens"]) name = "test_{}".format(n) method.__name__ = name method.__doc__ = "Run fixture {} - {}".format(case_file, n) setattr(cls, name, method) for n, data in enumerate(cases): attach_case(n, data)
def test_ast_renderer(self): md = Markdown(renderer=AstRenderer(), plugins=[_plugin]) data = fixtures.load_json(plugin_name + ".json") self.assertEqual(md(data["text"]), data["tokens"])
def test_ast_renderer(self): md = create_markdown(renderer='ast', plugins=[DirectiveToc()]) data = fixtures.load_json('toc.json') self.assertEqual(md(data['text']), data['tokens'])
def github_payload(): return fixtures.load_json( fixtures.get_for_reals_path('github_webhook.json') )
def travis_payload(): return fixtures.load_json( fixtures.get_for_reals_path('travis_webhook.json') )