aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2019-01-03 23:43:56 +0100
committerAnders Broman <a.broman58@gmail.com>2019-01-05 06:46:54 +0000
commit2e411dba93bf2ceecf3dd201b2d100864229ce02 (patch)
treed6fc878b4b9962d6ee364eca05d32142c2e1346f /test
parentf100f7f122885418dfd4d65a062632c6bbdd20c7 (diff)
test: allow running pytest without specifying the tests directory
This allows `pytest` to be executed from the top-level source or build directory (or any other directory below). Change-Id: Ib7af2ea2aaf01319d6839d2dc67228fbb5a7bc34 Reviewed-on: https://code.wireshark.org/review/31370 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/conftest.py9
-rw-r--r--test/pytest.ini3
2 files changed, 7 insertions, 5 deletions
diff --git a/test/conftest.py b/test/conftest.py
index c2646bf7a8..2146cb46a3 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -6,8 +6,9 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
-'''py.test configuration'''
+'''pytest configuration'''
+import re
import fixtures
def pytest_addoption(parser):
@@ -27,7 +28,11 @@ def pytest_collection_modifyitems(items):
global _all_test_groups
suites = []
for item in items:
- name = item.nodeid.split("::")[0].replace(".py", "").replace("/", ".")
+ name = item.nodeid.split("::")[0].replace(".py", "")
+ # When executed from the rootdir (e.g. "pytest test"), be sure to strip
+ # all preceding components ("test/suite_io" -> "suite_io").
+ name = re.sub(r'^.*/suite_', 'suite_', name)
+ name = name.replace("/", ".")
if name not in suites:
suites.append(name)
_all_test_groups = sorted(suites)
diff --git a/test/pytest.ini b/test/pytest.ini
deleted file mode 100644
index 4ec2f9ee11..0000000000
--- a/test/pytest.ini
+++ /dev/null
@@ -1,3 +0,0 @@
-[pytest]
-python_files=suite_*.py group_*.py
-addopts = -ra