From 535bcab3104bf69c2b4acb4da2fd650595cbf8b6 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 3 Nov 2015 07:00:46 +0100 Subject: [PATCH] bdd tests: Restart qutebrowser once per module. This should be a good compromise between reproducibility and speed. --- tests/integration/features/conftest.py | 9 +++++++-- tests/integration/features/zoom.feature | 5 +---- tests/integration/quteprocess.py | 10 ++++++++-- tests/integration/testprocess.py | 4 ++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/tests/integration/features/conftest.py b/tests/integration/features/conftest.py index 8a78f72b2..2f2a20ebb 100644 --- a/tests/integration/features/conftest.py +++ b/tests/integration/features/conftest.py @@ -34,7 +34,7 @@ def set_setting(quteproc, sect, opt, value): @bdd.given(bdd.parsers.parse("I open {path}")) -def open_path(quteproc, path): +def open_path_given(quteproc, path): quteproc.open_path(path, new_tab=True) @@ -43,8 +43,13 @@ def open_path_when(quteproc, path): quteproc.open_path(path) +@bdd.given(bdd.parsers.parse("I run {command}")) +def run_command_given(quteproc, command): + quteproc.send_cmd(command) + + @bdd.when(bdd.parsers.parse("I run {command}")) -def run_command(quteproc, command): +def run_command_when(quteproc, command): quteproc.send_cmd(command) diff --git a/tests/integration/features/zoom.feature b/tests/integration/features/zoom.feature index 3dfca5df2..6080eb59a 100644 --- a/tests/integration/features/zoom.feature +++ b/tests/integration/features/zoom.feature @@ -2,6 +2,7 @@ Feature: Zooming in and out Background: Given I open data/hello.txt + And I run :tab-only Scenario: Zooming in When I run :zoom-in @@ -9,7 +10,6 @@ Feature: Zooming in and out And the session should look like: windows: - tabs: - - ... - history: - zoom: 1.1 @@ -19,7 +19,6 @@ Feature: Zooming in and out And the session should look like: windows: - tabs: - - ... - history: - zoom: 0.9 @@ -29,7 +28,6 @@ Feature: Zooming in and out And the session should look like: windows: - tabs: - - ... - history: - zoom: 0.5 @@ -40,6 +38,5 @@ Feature: Zooming in and out And the session should look like: windows: - tabs: - - ... - history: - zoom: 1.0 diff --git a/tests/integration/quteprocess.py b/tests/integration/quteprocess.py index 736466802..aaa01e077 100644 --- a/tests/integration/quteprocess.py +++ b/tests/integration/quteprocess.py @@ -223,11 +223,17 @@ class QuteProc(testprocess.Process): line.expected = True -@pytest.yield_fixture +@pytest.yield_fixture(scope='module') def quteproc(qapp, httpbin): """Fixture for qutebrowser process.""" proc = QuteProc(httpbin) proc.start() yield proc proc.terminate() - proc.after_test() + + +@pytest.yield_fixture(autouse=True) +def httpbin_after_test(quteproc): + """Fixture to run cleanup tasks after each test.""" + yield + quteproc.after_test() diff --git a/tests/integration/testprocess.py b/tests/integration/testprocess.py index 6da284245..ced7844f9 100644 --- a/tests/integration/testprocess.py +++ b/tests/integration/testprocess.py @@ -145,11 +145,11 @@ class Process(QObject): self._data.clear() if self._invalid: raise InvalidLine + if not self.is_running(): + raise ProcessExited def terminate(self): """Clean up and shut down the process.""" - if not self.is_running(): - raise ProcessExited self.proc.terminate() self.proc.waitForFinished()