From eba485f5ebef6975c60eb29e69e03aa7598d59b8 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 23 Jul 2012 19:25:57 +1200 Subject: [PATCH] 100% unit test coverage --- libpathod/rparse.py | 4 ++-- test/test_rparse.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libpathod/rparse.py b/libpathod/rparse.py index e4b628224..5e435628c 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 88c1b6178..70395bdcc 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"