def test_mkd_compile(self): self.assertEqual( libmarkdown.mkd_compile.argtypes, (ctypes.POINTER(libmarkdown.Document), ctypes.c_int), ) self.assertEqual( libmarkdown.mkd_compile.restype, ctypes.c_int, ) text = '`test`' cp = ctypes.c_char_p(text) doc = libmarkdown.mkd_string(cp, len(text), 0) ret = libmarkdown.mkd_compile(doc, 0) self.assertNotEqual(ret, -1) self.assertEqual(doc.contents.compiled, 1) libmarkdown.mkd_cleanup(doc)
def test_mkd_generatehtml(self): self.assertEqual( libmarkdown.mkd_generatehtml.argtypes, (ctypes.POINTER(libmarkdown.Document), ctypes.POINTER(libmarkdown.FILE)), ) self.assertEqual( libmarkdown.mkd_generatehtml.restype, ctypes.c_int, ) text = '`test`' cp = ctypes.c_char_p(text) out = tempfile.TemporaryFile('r+w') doc = libmarkdown.mkd_string(cp, len(text), 0) ret = libmarkdown.mkd_compile(doc, 0) self.assertNotEqual(ret, -1) ret = libmarkdown.mkd_generatehtml( doc, ctypes.pythonapi.PyFile_AsFile(out), 0 ) self.assertNotEqual(ret, -1) out.seek(0) html = out.read() self.assertEqual( html, '<p><code>test</code></p>\n', ) libmarkdown.mkd_cleanup(doc) out.close()