Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved error import exception tests #968

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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