aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-07-23 19:25:57 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-07-23 19:25:57 +1200
commiteba485f5ebef6975c60eb29e69e03aa7598d59b8 (patch)
tree41463bcedfb05e3ee7655da51327a368e74d0e5a
parent763e1ff7862e8784170e7c23a015eceaa19e2f70 (diff)
downloadmitmproxy-eba485f5ebef6975c60eb29e69e03aa7598d59b8.tar.gz
mitmproxy-eba485f5ebef6975c60eb29e69e03aa7598d59b8.tar.bz2
mitmproxy-eba485f5ebef6975c60eb29e69e03aa7598d59b8.zip
100% unit test coverage
-rw-r--r--libpathod/rparse.py4
-rw-r--r--test/test_rparse.py7
2 files changed, 8 insertions, 3 deletions
diff --git a/libpathod/rparse.py b/libpathod/rparse.py
index e4b62822..5e435628 100644
--- a/libpathod/rparse.py
+++ b/libpathod/rparse.py
@@ -84,7 +84,7 @@ def write_values(fp, vals, actions, sofar=0, skip=0, blocksize=BLOCKSIZE):
send_chunk(fp, a[2], blocksize, 0, len(a[2]))
send_chunk(fp, v, blocksize, offset, len(v))
sofar += len(v)
- except tcp.NetLibDisconnect:
+ except tcp.NetLibDisconnect: # pragma: no cover
return True
@@ -188,7 +188,7 @@ class _Value:
def get_generator(self, settings):
return LiteralGenerator(self.val)
- def __str__(self):
+ def __repr__(self):
return self.val
diff --git a/test/test_rparse.py b/test/test_rparse.py
index 88c1b617..70395bdc 100644
--- a/test/test_rparse.py
+++ b/test/test_rparse.py
@@ -38,6 +38,7 @@ class TestMisc:
assert g[0] == "x"
assert g[-1] == "x"
assert g[0:5] == "xxxxx"
+ assert repr(g)
def test_valueliteral(self):
v = rparse.ValueLiteral("foo")
@@ -47,10 +48,12 @@ class TestMisc:
v = rparse.ValueLiteral(r"foo\n")
assert v.expr()
assert v.val == "foo\n"
+ assert repr(v)
def test_valuenakedliteral(self):
v = rparse.ValueNakedLiteral("foo")
assert v.expr()
+ assert repr(v)
def test_file_value(self):
v = rparse.Value.parseString("<'one two'")[0]
@@ -104,7 +107,9 @@ class TestMisc:
def test_path(self):
e = rparse.Path.expr()
assert e.parseString('"/foo"')[0].value.val == "/foo"
-
+ e = rparse.Path("/foo")
+ assert e.value.val == "/foo"
+
def test_method(self):
e = rparse.Method.expr()
assert e.parseString("get")[0].value.val == "GET"