Exemple #1
0
def test_Meta():
    element = Meta(charset="UTF-8")  # noqa: E501
    with open('file14.html', 'w') as file1fh:
        element.render(file1fh)
    with open('file14.html', 'r') as filefh:
        rendered = filefh.read()
    assert '<meta charset="UTF-8"/>\n' == rendered  # noqa: E501
def test_step8():
    html_el = Html('test')
    f = StringIO()
    html_el.render(f)
    assert f.getvalue() == ('<!DOCTYPE html>\n<html>\n    test\n</html>\n')

    meta = Meta(charset="UTF-8")
    assert meta.attr == {'charset': 'UTF-8'}
    f = StringIO()
    meta.render(f)
    assert f.getvalue() == ('<meta charset="UTF-8" />\n')
Exemple #3
0
def test_meta():
    """
    test the meta tag
    """
    m = Meta(charset="UTF-8")
    file_contents = render_result(m)
    print(file_contents)

    assert file_contents == '<meta charset="UTF-8" />'
Exemple #4
0
def test_meta_element():
    # <meta charset="UTF-8" />
    p = Meta(charset="UTF-8")
    contents = render_element(p).strip()
    lines = contents.split('\n')
    print(contents)
    assert len(lines) == 1
    assert lines[0].startswith('<meta charset=')
    assert lines[0].endswith('"UTF-8" />')
Exemple #5
0
def test_doctype_meta():
    page = Html()
    head = Head()
    head.append(Meta(charset="UTF-8"))
    page.append(head)

    f = StringIO()
    page.render(f, "")

    assert f.getvalue() == '<!DOCTYPE html>\n<html>\n'\
        '    <head>\n'\
        '        <meta charset="UTF-8" />\n'\
        '    </head>\n'\
        '</html>'
Exemple #6
0
def test_whole_thing():
    """
    Render a complete page

    This is not really a unit test, and does not test that the results
    are correct, but does ensure that it all runs, and provides output
    to look at
    """
    page = Html()

    head = Head()
    head.append(Meta(charset="UTF-8"))
    head.append(Title("Python Class Sample page"))
    page.append(head)

    body = Body()

    body.append(H(2, "Python Class - Html rendering example"))

    body.append(
        P(
            "Here is a paragraph of text -- there could be more of them, "
            "but this is enough to show that we can do some text",
            style="text-align: center; font-style: oblique;"))

    body.append(Hr())

    list = Ul(id="TheList", style="line-height:200%")

    list.append(Li("The first item in a list"))
    list.append(Li("This is the second item", style="color: red"))

    item = Li()
    item.append("And this is a ")
    item.append(A("http://google.com", "link"))
    item.append("to google")

    list.append(item)

    body.append(list)

    page.append(body)

    # Element.indent = "        "
    # now render it:
    with open("sample_output.html", 'w') as f:
        page.render(f)
 def test_render(self):
     p = Meta()
     f = StringIO()
     p.render(f)
     expected = "<meta charset=" + '"' + "UTF-8" + '"' + " /> \n"
     self.assertEqual(expected, f.getvalue())
Exemple #8
0
def test_meta():
    test = Meta()
    f = StringIO()
    test.render(f)
    assert f.getvalue() == '<meta />\n'
def test_meta_single_attribute():
    meta_tag = Meta(charset="UTF-8")
    results = render_element(meta_tag)
    print(results)
    assert results.startswith('<meta charset="UTF-8">')