Skip to content

Commit 78cccef

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 fc201ea commit 78cccef

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/diffpy/Structure/tests/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,16 @@ def testsuite(pattern=''):
3434
The TestSuite object containing the matching tests.
3535
'''
3636
import re
37+
from os.path import dirname
3738
from itertools import chain
3839
from pkg_resources import resource_filename
3940
loader = unittest.defaultTestLoader
4041
thisdir = resource_filename(__name__, '')
41-
suite_all = loader.discover(thisdir, pattern='Test*.py')
42+
depth = __name__.count('.') + 1
43+
topdir = thisdir
44+
for i in range(depth):
45+
topdir = dirname(topdir)
46+
suite_all = loader.discover(thisdir, pattern='Test*.py', top_level_dir=topdir)
4247
# always filter the suite by pattern to test-cover the selection code.
4348
suite = unittest.TestSuite()
4449
rx = re.compile(pattern)

0 commit comments

Comments
 (0)