aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_console_contentview.py23
-rw-r--r--test/test_utils.py58
2 files changed, 20 insertions, 61 deletions
diff --git a/test/test_console_contentview.py b/test/test_console_contentview.py
index babe59ea..cf2ab1e5 100644
--- a/test/test_console_contentview.py
+++ b/test/test_console_contentview.py
@@ -57,15 +57,32 @@ class uContentView(libpry.AutoTree):
assert cv.view_urlencoded([], d)
assert not cv.view_urlencoded([], "foo")
+ def test_view_html(self):
+ s = "<html><br><br></br><p>one</p></html>"
+ assert cv.view_html([], s)
+
+ s = "gobbledygook"
+ assert not cv.view_html([], s)
+
def test_view_json(self):
cv.VIEW_CUTOFF = 100
assert cv.view_json([], "{}")
assert not cv.view_urlencoded([], "{")
assert cv.view_json([], "[" + ",".join(["0"]*cv.VIEW_CUTOFF) + "]")
- def test_view_xmlish(self):
- assert cv.view_xmlish([], "<foo></foo>")
- assert cv.view_xmlish([], "<foo>")
+ def test_view_xml(self):
+ #assert cv.view_xml([], "<foo></foo>")
+ #assert not cv.view_xml([], "<foo>")
+
+ s = """<?xml version="1.0" encoding="UTF-8"?>
+ <?xml-stylesheet title="XSL_formatting"?>
+ <rss
+ xmlns:media="http://search.yahoo.com/mrss/"
+ xmlns:atom="http://www.w3.org/2005/Atom"
+ version="2.0">
+ </rss>
+ """
+ print cv.view_xml([], s)
def test_view_raw(self):
assert cv.view_raw([], "foo")
diff --git a/test/test_utils.py b/test/test_utils.py
index e445614a..f279ce65 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -58,63 +58,6 @@ class uData(libpry.AutoTree):
libpry.raises("does not exist", utils.pkg_data.path, "nonexistent")
-
-class upretty_xmlish(libpry.AutoTree):
- def test_tagre(self):
- def f(s):
- return re.search(utils.TAG, s, re.VERBOSE|re.MULTILINE)
- assert f(r"<body>")
- assert f(r"<body/>")
- assert f(r"< body/>")
- assert f(r"< body/ >")
- assert f(r"< body / >")
- assert f(r"<foo a=b>")
- assert f(r"<foo a='b'>")
- assert f(r"<foo a='b\"'>")
- assert f(r'<a b=(a.b) href="foo">')
- assert f('<td width=25%>')
- assert f('<form name="search" action="/search.php" method="get" accept-charset="utf-8" class="search">')
- assert f('<img src="gif" width="125" height="16" alt=&quot;&quot; />')
-
-
- def test_all(self):
- def isbalanced(ret):
- # The last tag should have no indent
- assert ret[-1].strip() == ret[-1]
-
- s = "<html><br><br></br><p>one</p></html>"
- ret = utils.pretty_xmlish(s)
- isbalanced(ret)
-
- s = r"""
-<body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onload="document.f.q.focus();if(document.images)new Image().src='/images/srpr/nav_logo27.png'" ><textarea id=csi style=display:none></textarea></body>
- """
- isbalanced(utils.pretty_xmlish(textwrap.dedent(s)))
-
- s = r"""
- <a href="http://foo.com" target="">
- <img src="http://foo.gif" alt="bar" height="25" width="132">
- </a>
- """
- isbalanced(utils.pretty_xmlish(textwrap.dedent(s)))
-
- s = r"""
- <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
- \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
- <html></html>
- """
- ret = utils.pretty_xmlish(textwrap.dedent(s))
- isbalanced(ret)
-
- s = "<html><br/><p>one</p></html>"
- ret = utils.pretty_xmlish(s)
- assert len(ret) == 6
- isbalanced(ret)
-
- s = "gobbledygook"
- assert utils.pretty_xmlish(s) == ["gobbledygook"]
-
-
class upretty_json(libpry.AutoTree):
def test_one(self):
s = json.dumps({"foo": 1})
@@ -242,7 +185,6 @@ tests = [
uhexdump(),
upretty_size(),
uData(),
- upretty_xmlish(),
upretty_json(),
u_urldecode(),
udel_all(),