Ejemplo n.º 1
0
def test_Title():
    element = Title('data1')
    element.append('data2')
    with open('file7.html', 'w') as file1fh:
        element.render(file1fh)
    with open('file7.html', 'r') as filefh:
        rendered = filefh.read()
    assert '<title> '+element.indent+'data1 '+element.indent+'data2 '+'</title>\n' == rendered  # noqa: E501
Ejemplo n.º 2
0
def test_title_render():
    my_stuff = 'bye bye ms american pie'
    titleobj = Title(my_stuff)
    more_stuff = ' drove my chevy to the levy'
    titleobj.append(more_stuff)
    contents = render_element(titleobj)
    contents = contents.strip()
    assert contents.startswith('<title>')
    assert contents.endswith('</title>')
    assert my_stuff in contents
    assert more_stuff in contents
Ejemplo n.º 3
0
def test_title_indendation_twothings():
    my_stuff = "Q: Where in the world is Grover Norquist?"
    more_stuff = "A: Pretending the Laffer curve is relevant"
    el_object = Title(my_stuff)
    body_object = Body(more_stuff)
    el_object.append(body_object)
    contents = render_element(el_object)
    contents = contents.strip()
    print(contents)
    lines = contents.split('\n')
    assert len(lines) == 1
    assert lines[0].startswith('<title> ')
    assert my_stuff in lines[0]
Ejemplo n.º 4
0
def test_Title():
    outfile = io.StringIO()

    e = Title('This is some text')
    e.append('This is some more text')

    e.render(outfile)

    outfile.seek(0)
    file_contents = outfile.read()

    print(file_contents)

    assert('This is some text') in file_contents
    assert('This is some more text') in file_contents

    assert file_contents.startswith("<title>")
    assert file_contents.strip().endswith("</title>")