Exemple #1
0
 def test_can_write_raw_html(self):
     out = HTMLOutputStream()
     out.start_tag("foo")
     out.write_text("bar")
     out.end_tag("foo")
     out.write_html("<baz>qux</baz>")
     assert str(out) == "<foo>bar</foo><baz>qux</baz>"
Exemple #2
0
 def test_void_elements_do_not_need_to_end(self):
     out = HTMLOutputStream()
     out.start_tag("foo")
     out.start_tag("bar")
     out.write_text("baz")
     out.start_tag("qux", void=True)
     out.close()
     assert str(out) == "<foo><bar>baz<qux></bar></foo>"
Exemple #3
0
 def test_cannot_write_badly_nested_elements(self):
     out = HTMLOutputStream()
     out.start_tag("foo")
     out.start_tag("bar")
     out.write_text("baz")
     out.end_tag("foo")
     try:
         out.end_tag("bar")
         assert False
     except ValueError:
         assert True
Exemple #4
0
 def test_elements_will_all_end_on_close(self):
     out = HTMLOutputStream()
     out.start_tag("foo")
     out.start_tag("bar")
     out.write_text("baz")
     out.close()
     assert str(out) == "<foo><bar>baz</bar></foo>"
Exemple #5
0
 def test_elements_will_end_in_sequence(self):
     out = HTMLOutputStream()
     out.start_tag("foo")
     out.start_tag("bar")
     out.write_text("baz")
     out.end_tag("foo")
     assert str(out) == "<foo><bar>baz</bar></foo>"
Exemple #6
0
 def test_can_write_nested_elements(self):
     out = HTMLOutputStream()
     out.start_tag("foo")
     out.start_tag("bar")
     out.write_text("baz")
     out.end_tag("bar")
     out.end_tag("foo")
     assert str(out) == "<foo><bar>baz</bar></foo>"
Exemple #7
0
 def test_can_write_tag_with_attributes_containing_entities(self):
     out = HTMLOutputStream()
     out.start_tag("foo", {"bar": "baz", "spam": "bacon & eggs"})
     out.write_text("qux")
     out.end_tag("foo")
     assert str(out) == '<foo bar="baz" spam="bacon &amp; eggs">qux</foo>'
Exemple #8
0
 def test_can_use_default_end_tag(self):
     out = HTMLOutputStream()
     out.start_tag("foo")
     out.write_text("bar")
     out.end_tag()
     assert str(out) == "<foo>bar</foo>"
Exemple #9
0
 def test_can_write_start_and_end_tags(self):
     out = HTMLOutputStream()
     out.start_tag("foo")
     out.write_text("bar")
     out.end_tag("foo")
     assert str(out) == "<foo>bar</foo>"
Exemple #10
0
 def test_can_write_void_tag(self):
     out = HTMLOutputStream()
     out.write_text("foo")
     out.start_tag("br")
     out.write_text("bar")
     assert str(out) == "foo<br>bar"
Exemple #11
0
 def test_can_write_text_with_greater_than_symbol(self):
     out = HTMLOutputStream()
     out.write_text("foo > bar")
     assert str(out) == "foo &gt; bar"
Exemple #12
0
 def test_can_write_text_with_less_than_symbol(self):
     out = HTMLOutputStream()
     out.write_text("foo < bar")
     assert str(out) == "foo &lt; bar"
Exemple #13
0
 def test_can_write_text_with_apostrophes(self):
     out = HTMLOutputStream()
     out.write_text("foo 'bar'")
     assert str(out) == "foo &apos;bar&apos;"
Exemple #14
0
 def test_can_write_text_with_quotes(self):
     out = HTMLOutputStream()
     out.write_text("foo \"bar\"")
     assert str(out) == "foo &quot;bar&quot;"
Exemple #15
0
 def test_can_write_text_with_ampersand(self):
     out = HTMLOutputStream()
     out.write_text("foo & bar")
     assert str(out) == "foo &amp; bar"
Exemple #16
0
 def test_can_write_text(self):
     out = HTMLOutputStream()
     out.write_text("foo")
     assert str(out) == "foo"