From c016c77da46a5f777bed3f4838e0962a60589e0f Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Tue, 29 Mar 2016 01:37:40 +0200 Subject: [PATCH] Try to fix Windows path issue with new custom step On windows, using '/' in pathnames won't work, so it's impossible to use to describe a path in a feature spec. The solution is to move the path logic out of the feature spec and hand it over to `os.path.join` in a new custom step for userscripts. --- tests/integration/features/conftest.py | 14 +++++++++++++- tests/integration/features/spawn.feature | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/integration/features/conftest.py b/tests/integration/features/conftest.py index b22cf0924..2ef565e66 100644 --- a/tests/integration/features/conftest.py +++ b/tests/integration/features/conftest.py @@ -129,11 +129,23 @@ def run_command(quteproc, httpbin, command): else: count = None command = command.replace('(port)', str(httpbin.port)) - command = command.replace('(datapath)', utils.abs_datapath(__file__)) quteproc.send_cmd(command, count=count) +@bdd.when(bdd.parsers.parse("I execute the userscript {userscript}")) +def run_userscript(quteproc, userscript): + """Run a userscript located in tests/integration/data/userscripts. + + Wrapper around :spawn --userscript {userscript} that uses an absolute + path. + """ + abs_userscript_path = os.path.join(utils.abs_datapath(__file__), + 'userscripts', userscript) + cmd = ':spawn --userscript {abs_userscript_path}' + quteproc.send_cmd(cmd.format(abs_userscript_path=abs_userscript_path)) + + @bdd.when(bdd.parsers.parse("I reload")) def reload(qtbot, httpbin, quteproc, command): """Reload and wait until a new request is received.""" diff --git a/tests/integration/features/spawn.feature b/tests/integration/features/spawn.feature index 9ec2a046f..eba2496fc 100644 --- a/tests/integration/features/spawn.feature +++ b/tests/integration/features/spawn.feature @@ -17,7 +17,7 @@ Feature: :spawn Then "Executing echo with args ['about:blank'], userscript=False" should be logged Scenario: Running :spawn with userscript - When I run :spawn --userscript (datapath)/userscripts/open_current_url + When I execute the userscript open_current_url And I wait until about:blank is loaded Then the following tabs should be open: - about:blank