Example #1
0
def test_head_tag():
    # assert newobj.tag == 'head'
    my_stuff = 'any string I like'
    head_obj = Head(my_stuff)
    contents = render_element(head_obj)
    contents = contents.strip()
    assert my_stuff in contents
    assert contents.startswith('<head>')
    assert contents.endswith('</head>')
def test_one_line_tag():
    e1 = Html("")
    e2 = Head("")
    e3 = Title("Hark! A Title!")
    e2.append(e3)
    e1.append(e2)
    output = get_output(e1)
    print(output)
    output_lines = get_output_lines(e1)
    assert "        <title>Hark! A Title!</title>" in output_lines
Example #3
0
def test_head():
    outfile = io.StringIO()

    e = Head("this is some text")
    e.append("and this is some more text")
    e.render(outfile)

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

    assert ("this is some text") in file_contents
    assert ("and this is some more text") in file_contents
def test_head():
    """
    testing Head with a title in it -- it should never be blank
    """
    h = Head()
    h.append(Title("A nifty title for the page"))
    file_contents = render_element(h, cur_ind='   ')

    print(file_contents)
    assert file_contents.startswith("   <head>")
    assert file_contents.endswith("   </head>")

    assert "<title>" in file_contents
    assert "</title>" in file_contents
    assert "A nifty title for the page" in file_contents
Example #5
0
def test_Head():
    outfile = io.StringIO()

    e = Head('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("<head>")
    assert file_contents.strip().endswith("</head>")
Example #6
0
def test_step3():
    outfile = io.StringIO()

    p = Html()
    h = Head()
    h.append(Title('This is TITLE'))
    p.append(h)
    b = Body()
    b.append(P('This is P'))
    p.append(b)

    p.render(outfile)

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

    print(file_contents)

    assert('This is TITLE') in file_contents
    assert('This is P') in file_contents

    assert file_contents.startswith("<html>")
    assert file_contents.strip().endswith("</html>")
Example #7
0
def test_head():
    test = Head(content='a head tag')
    f = StringIO()
    test.render(f)
    assert f.getvalue() == '<head>\n    a head tag\n</head>\n'
Example #8
0
def test_type_Head():
    test_element = Head(content=None)
    assert isinstance(test_element, Head) is True