From 9fe02d55c979e2630c5c0fefbb8001b623febaa5 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 25 Nov 2015 17:19:16 +0100 Subject: [PATCH] bdd: Add "I press the keys ..." step. --- tests/integration/features/conftest.py | 5 +++++ tests/integration/quteprocess.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/tests/integration/features/conftest.py b/tests/integration/features/conftest.py index 0510c52a4..2291a503c 100644 --- a/tests/integration/features/conftest.py +++ b/tests/integration/features/conftest.py @@ -165,6 +165,11 @@ def wait_time(quteproc, delay): time.sleep(float(delay)) +@bdd.when(bdd.parsers.re('I press the keys? "(?P[^"]*)"')) +def press_keys(quteproc, keys): + quteproc.press_keys(keys) + + @bdd.then(bdd.parsers.parse('"{pattern}" should not be logged')) def ensure_not_logged(quteproc, pattern): quteproc.ensure_not_logged(message=pattern) diff --git a/tests/integration/quteprocess.py b/tests/integration/quteprocess.py index 2f18b1ece..537d76982 100644 --- a/tests/integration/quteprocess.py +++ b/tests/integration/quteprocess.py @@ -281,6 +281,10 @@ class QuteProc(testprocess.Process): with open(path, 'r', encoding='utf-8') as f: return f.read() + def press_keys(self, keys): + """Press the given keys using :fake-key.""" + self.send_cmd(':fake-key -g "{}"'.format(keys)) + @pytest.yield_fixture(scope='module') def quteproc(qapp, httpbin, request):