diff options
author | Ujjwal Verma <ujjwalverma1111@gmail.com> | 2017-05-17 11:05:49 +0530 |
---|---|---|
committer | Ujjwal Verma <ujjwalverma1111@gmail.com> | 2017-05-17 11:05:49 +0530 |
commit | 204d06f93f7c3fbdce38b12219c530e1eddc3e4d (patch) | |
tree | 78139cebc77247562a482827c6f2a9a926c59d7c /test | |
parent | 8eea05fcafde2410e6af0746c09a05c6d8d5a3e9 (diff) | |
download | mitmproxy-204d06f93f7c3fbdce38b12219c530e1eddc3e4d.tar.gz mitmproxy-204d06f93f7c3fbdce38b12219c530e1eddc3e4d.tar.bz2 mitmproxy-204d06f93f7c3fbdce38b12219c530e1eddc3e4d.zip |
Increased xml_html contentview coverage
Diffstat (limited to 'test')
3 files changed, 66 insertions, 0 deletions
diff --git a/test/mitmproxy/contentviews/test_xml_html.py b/test/mitmproxy/contentviews/test_xml_html.py index 2b0aee4d..8148fd4c 100644 --- a/test/mitmproxy/contentviews/test_xml_html.py +++ b/test/mitmproxy/contentviews/test_xml_html.py @@ -11,6 +11,13 @@ def test_simple(): v = full_eval(xml_html.ViewXmlHtml()) assert v(b"foo") == ('XML', [[('text', 'foo')]]) assert v(b"<html></html>") == ('HTML', [[('text', '<html></html>')]]) + assert v(b"<>") == ('XML', [[('text', '<>')]]) + assert v(b"<p") == ('XML', [[('text', '<p')]]) + + with open(data.path("simple.html")) as f: + input = f.read() + tokens = xml_html.tokenize(input) + assert str(next(tokens)) == "Tag(<!DOCTYPE html>)" @pytest.mark.parametrize("filename", [ @@ -18,6 +25,7 @@ def test_simple(): "cdata.xml", "comment.xml", "inline.html", + "test.html" ]) def test_format_xml(filename): path = data.path(filename) diff --git a/test/mitmproxy/contentviews/test_xml_html_data/test-formatted.html b/test/mitmproxy/contentviews/test_xml_html_data/test-formatted.html new file mode 100644 index 00000000..0eb60004 --- /dev/null +++ b/test/mitmproxy/contentviews/test_xml_html_data/test-formatted.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>Title</title> +</head> +<body> + <p> + Lorem ipsum dolor + <p> + sit amet, consectetur + <p> + adipiscing elit, sed + <p> + do eiusmod tempor + <p> + incididunt ut + <p> + labore et dolore + <p> + magna aliqua. + <p> + Ut enim ad minim + <p> + veniam, quis nostrud + <p> + exercitation + <p> + ullamco laboris + <p> + nisi ut aliquip ex ea + <p> + commodo consequat. + <p> + Duis aute irure + <p> + dolor in reprehenderit + <p> + in voluptate velit + <p> + esse cillum dolore + <p>eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> +</body> +</html> diff --git a/test/mitmproxy/contentviews/test_xml_html_data/test.html b/test/mitmproxy/contentviews/test_xml_html_data/test.html new file mode 100644 index 00000000..e74ac314 --- /dev/null +++ b/test/mitmproxy/contentviews/test_xml_html_data/test.html @@ -0,0 +1,14 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>Title</title> +</head> +<body> +<p>Lorem ipsum dolor<p>sit amet, consectetur <p>adipiscing elit, sed<p>do eiusmod tempor<p> incididunt ut<p> labore et dolore<p> magna aliqua. + <p>Ut enim ad minim <p>veniam, quis nostrud <p>exercitation <p>ullamco laboris <p> + nisi ut aliquip ex ea <p>commodo consequat.<p>Duis aute irure <p>dolor in reprehenderit <p>in voluptate velit<p> esse cillum dolore <p>eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> + + +</body> +</html>
\ No newline at end of file |