summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Albrecht <palbrecht@mailbox.org>2023-08-23 09:42:50 +0200
committerPhilipp Albrecht <palbrecht@mailbox.org>2023-08-28 13:17:08 +0200
commit3974725932c2e3e06bd16e73a3a6b6f15e1beec4 (patch)
tree0fa24bb3abdbe40e00793f2bb7cf9eff629cba31
parent21751603b48b507b1216479b05c0bfc711c1cdd9 (diff)
downloadqutebrowser-3974725932c2e3e06bd16e73a3a6b6f15e1beec4.tar.gz
qutebrowser-3974725932c2e3e06bd16e73a3a6b6f15e1beec4.zip
Normalize end2end data directory path
Given the following scenario: ``` When I open file://(testdata)/some/file.html Then file://(testdata)/some/file.html should be loaded ``` If the end2end data directory is not normalized, the scenario fails because we try to compare ``` file:///home/palbrecht/dev/qutebrowser/tests/helpers/../end2end/data/hints/link_inject.html?port=50… ``` to ``` file:///home/palbrecht/dev/qutebrowser/tests/end2end/data/hints/link_inject.html?port=50… ``` Normalizing the path resolves the `..` and fixes the issue.
-rw-r--r--tests/end2end/features/conftest.py9
-rw-r--r--tests/helpers/testutils.py4
2 files changed, 6 insertions, 7 deletions
diff --git a/tests/end2end/features/conftest.py b/tests/end2end/features/conftest.py
index d25905bfe..62a81c5fc 100644
--- a/tests/end2end/features/conftest.py
+++ b/tests/end2end/features/conftest.py
@@ -33,8 +33,7 @@ def _get_echo_exe_path():
Path to the "echo"-utility.
"""
if utils.is_windows:
- return os.path.join(testutils.abs_datapath(), 'userscripts',
- 'echo.bat')
+ return str(testutils.abs_datapath() / 'userscripts' / 'echo.bat')
else:
return shutil.which("echo")
@@ -199,7 +198,7 @@ def open_path(quteproc, server, path):
- With "... as a URL", it's opened according to new_instance_open_target.
"""
path = path.replace('(port)', str(server.port))
- path = path.replace('(testdata)', testutils.abs_datapath())
+ path = path.replace('(testdata)', os.fspath(testutils.abs_datapath()))
new_tab = False
new_bg_tab = False
@@ -271,7 +270,7 @@ def run_command(quteproc, server, tmpdir, command):
invalid = False
command = command.replace('(port)', str(server.port))
- command = command.replace('(testdata)', testutils.abs_datapath())
+ command = command.replace('(testdata)', str(testutils.abs_datapath()))
command = command.replace('(tmpdir)', str(tmpdir))
command = command.replace('(dirsep)', os.sep)
command = command.replace('(echo-exe)', _get_echo_exe_path())
@@ -365,7 +364,7 @@ def hint(quteproc, args):
@bdd.when(bdd.parsers.parse('I hint with args "{args}" and follow {letter}'))
def hint_and_follow(quteproc, args, letter):
- args = args.replace('(testdata)', testutils.abs_datapath())
+ args = args.replace('(testdata)', str(testutils.abs_datapath()))
args = args.replace('(python-executable)', sys.executable)
quteproc.send_cmd(':hint {}'.format(args))
quteproc.wait_for(message='hints: *')
diff --git a/tests/helpers/testutils.py b/tests/helpers/testutils.py
index dc6fdac32..a6022a6f9 100644
--- a/tests/helpers/testutils.py
+++ b/tests/helpers/testutils.py
@@ -192,8 +192,8 @@ def pattern_match(*, pattern, value):
def abs_datapath():
"""Get the absolute path to the end2end data directory."""
- file_abs = os.path.abspath(os.path.dirname(__file__))
- return os.path.join(file_abs, '..', 'end2end', 'data')
+ path = pathlib.Path(__file__).parent / '..' / 'end2end' / 'data'
+ return path.resolve()
@contextlib.contextmanager