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.
This commit is contained in:
Philipp Hansch 2016-03-29 01:37:40 +02:00
parent e9ae2156d3
commit c016c77da4
2 changed files with 14 additions and 2 deletions

View File

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

View File

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