tests: Give more descriptive import error.

This code takes care of the environment running Python 3.4 when
test label is passed directly to the test-backend command:
./tools/test-backend test_alert_words
This commit is contained in:
Umair Khan
2018-01-18 12:19:51 +05:00
committed by showell
parent 0eda941822
commit a994dba583

View File

@@ -446,15 +446,11 @@ class Runner(DiscoverRunner):
except AttributeError: except AttributeError:
# We are likely to get here only when running tests in serial # We are likely to get here only when running tests in serial
# mode on Python 3.4 or lower. # mode on Python 3.4 or lower.
traceback.print_exc() # test_labels are always normalized to include the correct prefix.
print() # If we run the command with ./tools/test-backend test_alert_words,
print(" This is often caused by a test module/class/function that doesn't exist or ") # test_labels will be equal to ['zerver.tests.test_alert_words'].
print(" import properly. You can usually debug in a `./manage.py shell` via e.g. ") for test_label in test_labels:
print(" import zerver.tests.test_messages") check_import_error(test_label)
print(" from zerver.tests.test_messages import StreamMessagesTest")
print(" StreamMessagesTest.test_message_to_stream")
print()
sys.exit(1)
self.test_imports(test_labels, suite) self.test_imports(test_labels, suite)
if self.parallel == 1: if self.parallel == 1: