Skip to content

Commit 82c3a1e

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 e110f7e commit 82c3a1e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/diffpy/srreal/tests/__init__.py

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

0 commit comments

Comments
 (0)