Skip to content

Commit 82ade62

Browse files
committed
TST: avoid shadowing errors in test sources.
When some unit test module fails to import, use the discovered test suite as is without any test selection. Raise exception relevant to the module error rather then a later one from test selection failure.
1 parent 4a4b07a commit 82ade62

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/diffpy/srfit/tests/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def testsuite(pattern=''):
3333
----------
3434
pattern : str, optional
3535
Regular expression pattern for selecting test cases.
36-
Select all tests when empty.
36+
Select all tests when empty. Ignore the pattern when
37+
any of unit test modules fails to import.
3738
3839
Returns
3940
-------
@@ -54,7 +55,11 @@ def testsuite(pattern=''):
5455
# always filter the suite by pattern to test-cover the selection code.
5556
suite = unittest.TestSuite()
5657
rx = re.compile(pattern)
57-
tcases = chain.from_iterable(chain.from_iterable(suite_all))
58+
tsuites = list(chain.from_iterable(suite_all))
59+
tsok = all(isinstance(ts, unittest.TestSuite) for ts in tsuites)
60+
if not tsok: # pragma: no cover
61+
return suite_all
62+
tcases = chain.from_iterable(tsuites)
5863
for tc in tcases:
5964
tcwords = tc.id().rsplit('.', 2)
6065
shortname = '.'.join(tcwords[-2:])

0 commit comments

Comments
 (0)