From f9d7f20aac749079507aaaf58d7a205b05a136ba Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 28 Nov 2015 23:36:26 +0100 Subject: [PATCH] tests: Raise if wait_for is used without kwargs. Otherwise wait_for would return immediately because matches is empty so any(matches) is True. --- tests/integration/test_testprocess.py | 8 ++++++++ tests/integration/testprocess.py | 2 ++ 2 files changed, 10 insertions(+) diff --git a/tests/integration/test_testprocess.py b/tests/integration/test_testprocess.py index 5b8b50db9..830f0ff41 100644 --- a/tests/integration/test_testprocess.py +++ b/tests/integration/test_testprocess.py @@ -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: diff --git a/tests/integration/testprocess.py b/tests/integration/testprocess.py index 927782088..9a2c4134d 100644 --- a/tests/integration/testprocess.py +++ b/tests/integration/testprocess.py @@ -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