Skip to content

Commit

Permalink
Merge pull request #968 from sphuber/fix_953_improved_error_import_ex…
Browse files Browse the repository at this point in the history
…ception_tests

Improved error import exception tests
  • Loading branch information
sphuber authored Nov 30, 2017
2 parents 0a3fca1 + b424673 commit f3bc13d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion aiida/backends/testbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,19 @@ def run_aiida_db_tests(tests_to_run, verbose=False):

for modulename in modulenames:
if modulename not in found_modulenames:
test_suite.addTest(test_loader.loadTestsFromName(modulename))
try:
test_suite.addTest(test_loader.loadTestsFromName(modulename))
except AttributeError as exception:
try:
import importlib
import traceback
importlib.import_module(modulename)
except ImportError as exception:
print >> sys.stderr, (
"[CRITICAL] The module '{}' has an import error and the tests cannot be run:\n{}"
.format(modulename, traceback.format_exc(exception))
)
sys.exit(1)
found_modulenames.add(modulename)

num_tests_expected = test_suite.countTestCases()
Expand Down

0 comments on commit f3bc13d

Please sign in to comment.