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:
parent
f5febc4807
commit
f9d7f20aac
@ -136,6 +136,14 @@ class TestWaitFor:
|
|||||||
with pytest.raises(testprocess.WaitForTimeout):
|
with pytest.raises(testprocess.WaitForTimeout):
|
||||||
pyproc.wait_for(data="foobar", timeout=100)
|
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:
|
class TestEnsureNotLogged:
|
||||||
|
|
||||||
|
@ -254,6 +254,8 @@ class Process(QObject):
|
|||||||
timeout = 15000
|
timeout = 15000
|
||||||
else:
|
else:
|
||||||
timeout = 5000
|
timeout = 5000
|
||||||
|
if not kwargs:
|
||||||
|
raise TypeError("No keyword arguments given!")
|
||||||
for key in kwargs:
|
for key in kwargs:
|
||||||
assert key in self.KEYS
|
assert key in self.KEYS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user