Exemple #1
0
def test_Body():
    element = Body('data1')
    element.append('data2')
    with open('file4.html', 'w') as file1fh:
        element.render(file1fh)
    with open('file4.html', 'r') as filefh:
        rendered = filefh.read()
    assert '<body>\n'+element.indent+'data1\n'+element.indent+'data2\n'+'</body>\n' == rendered  # noqa: E501
def test_body_render():
    outfile = io.StringIO()

    b = Body("this is some text")

    b.render(outfile, ind=4)

    file_contents = outfile.getvalue()

    print(file_contents)
Exemple #3
0
def test_html_render():
    html_obj = Html("Some html text")
    html_obj.append("more html text")

    body_obj = Body("I am a body element")

    with open("test3.html", "w") as outfile:
        body_obj.render(outfile)

    with open("test2.html", "w") as outfile:
        html_obj.render(outfile)
 def test_render(self):
     p = Body()
     test_str = "this is a Body render test"
     p.append(test_str)
     f = StringIO()
     p.render(f)
     expected = [
         "<body>", p.indent * ' ' + "this is a Body render test", "</body>"
     ]
     expected_page = "\n".join(expected) + "\n"
     self.assertEqual(expected_page, f.getvalue())
def test_body():
    outfile = io.StringIO()

    e = Body("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_render_body():
    mystuff = 'spam, spam, spam'
    el_object = Body(mystuff)
    morestuff = 'eggs, eggs, eggs'
    el_object.append(morestuff)
    with open('text2.htm', 'w') as out_file:
        el_object.render(out_file)
    with open('text2.htm', 'r') as in_file:
        contents = in_file.read()
    assert contents.startswith('<body>')
    assert contents.endswith('</body>')
    assert mystuff in contents
    assert morestuff in contents
def test_render_body():
    my_stuff = 'hamma, hamma, hamma'
    el_object = Body(my_stuff)
    more_stuff = "umma, umma, umma"
    el_object.append(more_stuff)
    with open('testb', 'w') as out_file:
        el_object.render(out_file)
    with open('testb', 'r') as in_file:
        contents = in_file.read()
    assert contents.startswith('<body')
    assert contents.endswith('</body>')
    assert my_stuff in contents
    assert more_stuff in contents
Exemple #8
0
def test_render_body():
    some_stuff = 'blueberries and raspberries'
    el_object = Body(some_stuff)
    more_stuff = 'strawberries'
    el_object.append(more_stuff)
    with open('test1.txt', 'w') as out_file:
        el_object.render(out_file)
    with open('test1.txt', 'r') as in_file:
        contents = in_file.read()
    assert contents.startswith('<body>')
    assert contents.endswith('</body>')
    assert some_stuff in contents
    assert more_stuff in contents
Exemple #9
0
def test_render_page():
    my_stuff = 'nerp'
    more_stuff = 'eggs, eggs, eggs'
    el_object = Body(my_stuff)
    el_object.append(more_stuff)
    with open('test1', 'w') as out_file:
        el_object.render(out_file)
    with open('test1', 'r') as in_file:
        contents = in_file.read()
        assert contents.startswith('<body>')
        assert contents.endswith('</body>')
        assert my_stuff in contents
        assert more_stuff in contents
def test_Body():
    outfile = io.StringIO()

    e = Body('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
def test_body():
	outfile = io.StringIO()
	b = Body("this is some text")
	b.append ("and some more text")

	assert "and some more text" in b.content
	assert b.content == ["this is some text", "and some more text"]

	b.render(outfile, "")
	outfile.seek(0)
	file_contents = outfile.read()

	assert ("this is some text") in file_contents
	assert ("and some more text") in file_contents

	assert file_contents.startswith ("<body>\n")
	assert file_contents.strip().endswith ("</body>")
Exemple #12
0
def test_Body():
    outfile = io.StringIO()

    e = Body('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("<body>")
    assert file_contents.strip().endswith("</body>")
def test_render_body():
    my_stuff = 'spam, spam, spam'
    el_object = Body(my_stuff)
    more_stuff = ', eggs, eggs, eggs'
    el_object.append(more_stuff)
    with open('test_render_body_output.html', 'w') as out_file:
        el_object.render(out_file)
    with open('test_render_body_output.html', 'r') as in_file:
        contents = in_file.read()
    assert contents.startswith('<body>\n')
    assert contents.endswith('</body>\n')
    assert my_stuff in contents
    assert more_stuff in contents


#def test_render_non_strings():
#    # this is crating a html page with a single body() element in it
#    el_object = Html(Body('any string I like'))
#    with open('test_render_non_strings_output.html', 'w') as out_file:
#    	el_object.render(out_file)
#    with open('test_render_non_strings_output.html', 'r') as in_file:
#    	contents = in_file.read()
#    # make sure extra whitespace at beginning or end doesn't mess things up.
#    contents = contents.strip()

#    print(contents)  # so we can see what's going on if a test fails

# so what should the results be?
# the html tag is the outer tag, so the contents should start and end with that.
#    assert contents.startswith('<html>')
#    assert contents.endswith('</html>')

# the body tags had better be there too
#    assert '<body>' in contents
#    assert '</body' in contents

# we want the tesxt, too:
#    assert 'any string I like' in contents

# now lets get pretty specific:
# the opening tag should come before the ending tag
#    assert contents.index('<body>') < contents.index('</body>')
# the opening tag should come before the content
#    assert contents.index('<body>') < contents.index('any string')
Exemple #14
0
a.append ("some stuff")
a.append ("other stuff")

b=Body()
b.append ("body stuff")
b.append ("body stuff II")

#print (a.content)
#print (a.tag)

#print (b.content)
#print (b.tag)

#a.append(b)
#print (a.content)

outfile = io.StringIO()	
a.render (outfile, "")
b.render (outfile, "")

a.append(b)
#print (a.__class__.__name__)
a.render (outfile, "")
#print (a.content)

#c = "a string"
#print (c.__class__.__name__)

f = open('test.out', 'w')
f.write (a)
Exemple #15
0
def test_body():
    test = Body(content='a body tag')
    f = StringIO()
    test.render(f)
    assert f.getvalue() == '<body>\n    a body tag\n</body>\n'