Make last_log return None if nothing is logged.

This commit is contained in:
Aldo Cortesi 2013-02-23 21:46:01 +13:00
parent 5288848d03
commit 9c9e15341f
3 changed files with 4 additions and 5 deletions

View File

@ -34,12 +34,11 @@ class Daemon:
def last_log(self):
"""
Returns the last logged request. Raises AssertionError if no
requests have been logged.
Returns the last logged request, or None.
"""
l = self.log()
if not l:
raise AssertionError("No requests logged")
return None
return l[-1]
def log(self):

View File

@ -89,5 +89,5 @@ setup(
"Topic :: Software Development :: Testing :: Traffic Generation",
"Topic :: Internet :: WWW/HTTP",
],
install_requires=['netlib>=0.2.2', "requests>=1.0.4", "flask"],
install_requires=['netlib>=0.2.2', "requests>=1.1.0", "flask"],
)

View File

@ -96,7 +96,7 @@ class CommonTests(tutils.DaemonTests):
def test_logs(self):
assert self.d.clear_log()
tutils.raises("no requests logged", self.d.last_log)
assert not self.d.last_log()
rsp = self.get("202:da")
assert len(self.d.log()) == 1
assert self.d.clear_log()