summaryrefslogtreecommitdiff
path: root/tests/conftest.py
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2019-09-02 22:07:59 +0200
committerFlorian Bruhin <me@the-compiler.org>2019-09-02 22:09:52 +0200
commite8fab5175782772111ffde79095943599324f4ed (patch)
treec446be4570945a999eb17015d7d926b82f70be76 /tests/conftest.py
parent4a99cc1da6de698a9ce34a77e9a6990bc8cc0809 (diff)
downloadqutebrowser-e8fab5175782772111ffde79095943599324f4ed.tar.gz
qutebrowser-e8fab5175782772111ffde79095943599324f4ed.zip
Use pathlib to find out test basedir
This simplifies things a bit and also fixes an issue happening after https://github.com/pytest-dev/pytest/pull/5792 - presumably, the casing of the drive letter changed somehow.
Diffstat (limited to 'tests/conftest.py')
-rw-r--r--tests/conftest.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 0f84b0ab7..22effd499 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -24,6 +24,7 @@
import os
import sys
import warnings
+import pathlib
import ctypes
import ctypes.util
@@ -139,11 +140,10 @@ def pytest_collection_modifyitems(config, items):
item.add_marker('gui')
if hasattr(item, 'module'):
- module_path = os.path.relpath(
- item.module.__file__,
- os.path.commonprefix([__file__, item.module.__file__]))
+ test_basedir = pathlib.Path(__file__).parent
+ module_path = pathlib.Path(item.module.__file__)
+ module_root_dir = module_path.relative_to(test_basedir).parts[0]
- module_root_dir = module_path.split(os.sep)[0]
assert module_root_dir in ['end2end', 'unit', 'helpers',
'test_conftest.py']
if module_root_dir == 'end2end':