Skip to content

Commit ed1c2e5

Browse files
committed
TST: Use top_level_dir in test discovery.
top_level_dir affects the test case `id` which is used by codecov to match the source files.
1 parent 23ade08 commit ed1c2e5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/diffpy/srfit/tests/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,16 @@ def testsuite(pattern=''):
4141
The TestSuite object containing the matching tests.
4242
'''
4343
import re
44+
from os.path import dirname
4445
from itertools import chain
4546
from pkg_resources import resource_filename
4647
loader = unittest.defaultTestLoader
4748
thisdir = resource_filename(__name__, '')
48-
suite_all = loader.discover(thisdir)
49+
depth = __name__.count('.') + 1
50+
topdir = thisdir
51+
for i in range(depth):
52+
topdir = dirname(topdir)
53+
suite_all = loader.discover(thisdir, top_level_dir=topdir)
4954
# always filter the suite by pattern to test-cover the selection code.
5055
suite = unittest.TestSuite()
5156
rx = re.compile(pattern)

0 commit comments

Comments
 (0)