def test_two_instances():
    e = Element("this is some text")
    e2 = Element("this is some text")

    e.append("some more text")

    assert "some more text" not in e2.content
Beispiel #2
0
def test_two_instances():
    e = Element('this is some text')
    e2 = Element('this is some other text')

    e.append('some more text')

    assert 'some more text' not in e2.content
Beispiel #3
0
def test_two_instances():
    e = Element("this is also text")
    e2 = Element("this is also text")

    e.append("some more text")

    assert "some more text" in e.content
Beispiel #4
0
def test_render():
    element = Element('data1')
    element.append('data2')
    with open('file1.html', 'w') as file1fh:
        element.render(file1fh)
    with open('file1.html', 'r') as filefh:
        rendered = filefh.read()
    assert '<>\n'+element.indent+'data1\n'+element.indent+'data2\n'+'</>\n' == rendered  # noqa: E501
Beispiel #5
0
def test_append():
    '''test append method'''
    ANS = 2
    e = Element("foo")
    e.append("bar")

    result = e.get_content()
    assert result is ANS
 def test_append(self):
     """test append"""
     # create Element instance
     p = Element()
     expected = "This is a test"
     p.append(expected)
     actual = p.a_list[0]
     self.assertEqual(expected, actual)
Beispiel #7
0
def test_Element_kwargs():
    element = Element('data1', style="text-align: center; font-style: oblique;")  # noqa: E501
    element.tag = 'p'
    element.append('data2')
    with open('file8.html', 'w') as file1fh:
        element.render(file1fh)
    with open('file8.html', 'r') as filefh:
        rendered = filefh.read()
    assert '<p style="text-align: center; font-style: oblique;">\n'+element.indent+'data1\n'+element.indent+'data2\n'+'</p>\n' == rendered  # noqa: E501
def test_append():
    """
    This tests that you can append text

    It doesn't test if it works --
    that will be covered by the render test later
    """
    e = Element("this is some text")
    e.append("some more text")
def test_append():
	e = Element("this is some text")
	e.append ("and more text")

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

	e.append ("and even more text")
	assert e.content == ["this is some text", "and more text", "and even more text"]
def test_render():
    my_stuff = 'spam, spam, spam'
    el_object = Element(my_stuff)
    more_stuff = 'eggs, eggs, eggs'
    el_object.append(more_stuff)
    contents = render_element(el_object).strip()
    assert contents.startswith('<html>')
    assert contents.endswith('</html>')
    assert my_stuff in contents
    assert more_stuff in contents
def test_render():
    e = Element("this is some text")
    e.append("and this is some more text")

    file_contents = render_result(e)

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

    assert file_contents.startswith("<html>")
    assert file_contents.strip().endswith("</html>")
Beispiel #12
0
def test_render():
    outfile = io.StringIO()
    e = Element("this is some text")
    e.append("some more text")
    e.render(outfile)
    outfile.seek(0)
    file_contents = outfile.read()
    assert ("this is some text") in file_contents
    assert ("some more text") in file_contents
    assert file_contents.startswith("<html>")
    assert file_contents.strip().endswith("</html>")
def test_render():
    outfile = io.StringIO()
    e = Element('this is some text\n')
    e.append('this is again some more text')
    e.render(outfile)
    outfile.seek(0)
    file_contents = outfile.read()
    assert ('this is some text') in file_contents
    assert ('this is again some more text') in file_contents
    assert file_contents.startswith('<html>')
    assert file_contents.strip.endswith('</html>')
    print(file_contents)
def test_render():
    outfile = io.StringIO()

    e = Element("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():
	outfile = io.StringIO()		
	e = Element ("this is some text")
	e.append ("and some more text")
	#with open("test1.html", 'w') as outfile:
	#	e.render(outfile)
	e.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
def test_render_element():
    my_stuff = 'hamma, hamma, hamma'
    el_object = Element(my_stuff)
    more_stuff = "umma, umma, umma"
    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('<html>')
    assert contents.endswith('</html>')
    assert my_stuff in contents
    assert more_stuff in contents
Beispiel #17
0
def test_render():
    some_stuff = 'blueberries and raspberries'
    el_object = Element(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('<html>')
    assert contents.endswith('</html>')
    assert some_stuff in contents
    assert more_stuff in contents
def test_reder():
    mystuff = 'spam, spam, spam'
    el_object = Element(mystuff)
    morestuff = 'eggs, eggs, eggs'
    el_object.append(morestuff)
    with open('text1.htm', 'w') as out_file:
        el_object.render(out_file)
    with open('text1.htm', 'r') as in_file:
        contents = in_file.read()
    assert contents.startswith('<html>')
    assert contents.endswith('</html>')
    assert mystuff in contents
    assert morestuff in contents
 def test_render(self):
     """test render()"""
     p = Element()
     test_str = "this is a render test"
     # add content
     p.append(test_str)
     f = StringIO()
     # indent  4 spaces
     p.render(f, "    ")
     expected = [
         "    <html>", p.indent * ' ' + "    this is a render test",
         "    </html>"
     ]
     expected_page = "\n".join(expected) + "\n"
     self.assertEqual(expected_page, f.getvalue())
def test_step1():
    el = Element()
    assert el.tag == 'html'
    assert el.indent == 4
    assert el.content == []

    el.append('hi')
    assert el.content == ['hi']
    el.append('bye')
    assert el.content == ['hi', 'bye']

    f = StringIO()
    el.render(f)
    assert f.getvalue() == ('<html>\n    hi\n    bye\n</html>\n')

    f = StringIO()
    el.render(f, 1)
    assert f.getvalue() == ('    <html>\n        hi\n        bye\n    '
                            '</html>\n')
Beispiel #21
0
def test_tag():
    outfile = io.StringIO()

    e = Element("this is some text", "body")
    e.append("and this is some more text, WooHoo!!")

    e.render(outfile)

    outfile.seek(0)
    file_contents = outfile.read()
    #f = open('test1.html', 'w')
    #f.write(file_contents)
    open('test1.html', 'w').write(file_contents)

    print(file_contents)
    assert ("this is some text") in file_contents
    assert ("and this is some more text, WooHoo!!") in file_contents

    assert file_contents.startswith("<body>")
    assert file_contents.strip().endswith("</body>")
def test_render_element():
    """
    Tests whether the Element can render two pieces of text
    So it is also testing that the append method works correctly.

    It is not testing whether indentation or line feeds are correct.
    """
    e = Element("this is some text")
    e.append("and this is some more text")

    # This uses the render_results utility above
    file_contents = render_result(e).strip()

    # making sure the content got in there.
    assert ("this is some text") in file_contents
    assert ("and this is some more text") in file_contents

    # make sure it's in the right order
    assert file_contents.index("this is") < file_contents.index("and this")

    # making sure the opening and closing tags are right.
    assert file_contents.startswith("<html>")
    assert file_contents.endswith("</html>")
Beispiel #23
0
def test_append_string():
    el_object = Element('spam, spam, eggs')
    el_object.append(' and spam')
    assert el_object.content == ['spam, spam, eggs', ' and spam']
Beispiel #24
0
def test_render():
    e = Element("Some text")
    e.append("More text")
    with open("test1.html", 'w') as outfile:
        e.render(outfile)
Beispiel #25
0
def test_append():
    e = Element('this is some text')

    e.append('some more text')

    assert 'some more text' in e.content
Beispiel #26
0
def test_append():
    e = Element("this is some text")

    e.append("some more text")

    assert "some more text" in e.content
def test_append():
    e = Element("some text")
    e.append("some more text")
    assert e.content[-1] == "some more text"
Beispiel #28
0
def test_append():
    element = Element("data1")
    element.append("data2")
    assert element.content == ["data1", "data2"]
Beispiel #29
0
def test_append_content_element():
    test_element = Element()
    test_element.append('New content')
    assert test_element.content[0].text == 'New content'
def test_append_string():
    el_object = Element('spam, spam, spam')
    el_object.append(', wonderful spam')
    assert el_object.content == ['spam, spam, spam', ', wonderful spam']