100% unit test coverage

This commit is contained in:
Aldo Cortesi 2012-07-23 19:25:57 +12:00
parent 763e1ff786
commit eba485f5eb
2 changed files with 8 additions and 3 deletions

View File

@ -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

View File

@ -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"