from os import remove from tempfile import mktemp from pdfmajor.converters.writers.html import HTMLMaker # Make temp file FILE_NAME = mktemp() with HTMLMaker(FILE_NAME) as html: with html.elm("html", nolineend=True): html.write("test") assert(open(FILE_NAME, 'r').read() == """ test """) with HTMLMaker(FILE_NAME) as html: with html.elm("html", nolineend=True): with html.elm("head"): html.singleton("meta", { 'http-equiv': "Content-Type", 'content': "text/html" }) assert(open(FILE_NAME, 'r').read() == """
""") with HTMLMaker(FILE_NAME) as html: with html.elm("html", nolineend=True): with html.elm("head"): html.singleton("meta", { 'http-equiv': "Content-Type", 'content': "text/html" }) with html.elm("body"): with html.elm("h1", css={"color": "red"}): html.write("Hello World") assert(open(FILE_NAME, 'r').read() == """