File tree Expand file tree Collapse file tree 2 files changed +16
-15
lines changed
Expand file tree Collapse file tree 2 files changed +16
-15
lines changed Original file line number Diff line number Diff line change @@ -58,16 +58,16 @@ def pytest_generate_tests(metafunc):
5858 if len (tests_arg ):
5959 test_targets = tests_arg
6060 else :
61- # Default sibling directories used by the original runner
62- sibling_dirs = [
63- '../specifications/json-ld-api/tests/' ,
64- '../specifications/json-ld-framing/tests/' ,
65- '../specifications/normalization/tests/' ,
66- ]
61+ # Default sibling directories used by the original runner. Keep the
62+ # original relative strings but resolve them relative to this
63+ # `conftest.py` so tests can be discovered regardless of cwd.
64+ base_path = os .path .abspath (os .path .dirname (__file__ ))
65+
6766 test_targets = []
68- for d in sibling_dirs :
69- if os .path .exists (d ):
70- test_targets .append (d )
67+ for d in runtests .SIBLING_DIRS :
68+ d_path = os .path .abspath (os .path .join (base_path , d ))
69+ if os .path .exists (d_path ):
70+ test_targets .append (d_path )
7171
7272 if len (test_targets ) == 0 :
7373 pytest .skip ('No test manifest or directory specified (use --tests)' )
Original file line number Diff line number Diff line change 9090 'https://github.com/json-ld/normalization/tests'
9191]
9292
93+ SIBLING_DIRS = [
94+ '../specifications/json-ld-api/tests/' ,
95+ '../specifications/json-ld-framing/tests/' ,
96+ '../specifications/normalization/tests/' ,
97+ ]
98+
9399# NOTE: The following TestRunner class can be removed because pytest now
94100# provides the test harness; this class can be removed once the legacy
95101# CLI runner is deleted.
@@ -162,12 +168,7 @@ def main(self):
162168 else :
163169 # default to find known sibling test dirs
164170 test_targets = []
165- sibling_dirs = [
166- '../json-ld-api/tests/' ,
167- '../json-ld-framing/tests/' ,
168- '../normalization/tests/' ,
169- ]
170- for dir in sibling_dirs :
171+ for dir in SIBLING_DIRS :
171172 if os .path .exists (dir ):
172173 print ('Test dir found' , dir )
173174 test_targets .append (dir )
You can’t perform that action at this time.
0 commit comments