tests: Raise if wait_for is used without kwargs.

Otherwise wait_for would return immediately because matches is empty so
any(matches) is True.
This commit is contained in:
Florian Bruhin 2015-11-28 23:36:26 +01:00
parent f5febc4807
commit f9d7f20aac
2 changed files with 10 additions and 0 deletions

View File

@ -136,6 +136,14 @@ class TestWaitFor:
with pytest.raises(testprocess.WaitForTimeout):
pyproc.wait_for(data="foobar", timeout=100)
def test_no_kwargs(self, pyproc):
"""Using wait_for without kwargs should raise an exception.
Otherwise it'd match automatically because of the all(matches).
"""
with pytest.raises(TypeError):
pyproc.wait_for()
class TestEnsureNotLogged:

View File

@ -254,6 +254,8 @@ class Process(QObject):
timeout = 15000
else:
timeout = 5000
if not kwargs:
raise TypeError("No keyword arguments given!")
for key in kwargs:
assert key in self.KEYS