Make last_log return None if nothing is logged.
This commit is contained in:
parent
5288848d03
commit
9c9e15341f
|
@ -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):
|
||||
|
|
2
setup.py
2
setup.py
|
@ -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"],
|
||||
)
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue