bdd tests: Restart qutebrowser once per module.

This should be a good compromise between reproducibility and speed.
This commit is contained in:
Florian Bruhin 2015-11-03 07:00:46 +01:00
parent f5eb755ef3
commit 535bcab310
4 changed files with 18 additions and 10 deletions

View File

@ -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)

View File

@ -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

View File

@ -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()

View File

@ -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()