mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
tests: Make import failure error messages more consistent.
This commit is contained in:
@@ -354,13 +354,13 @@ class ParallelTestSuite(django_runner.ParallelTestSuite):
|
|||||||
self.subsuites = SubSuiteList(self.subsuites) # type: ignore # Type of self.subsuites changes.
|
self.subsuites = SubSuiteList(self.subsuites) # type: ignore # Type of self.subsuites changes.
|
||||||
|
|
||||||
def print_error_message(test_name: Text) -> None:
|
def print_error_message(test_name: Text) -> None:
|
||||||
|
command = [sys.executable, "-c", "import %s" % test_name]
|
||||||
print()
|
print()
|
||||||
print("Actual test to be run is %s, but import failed." % (test_name,))
|
print("Actual test to be run is %s, but import failed." % (test_name,))
|
||||||
print(" Importing test module directly to generate clearer traceback.")
|
print("Importing test module directly to generate clearer traceback:")
|
||||||
try:
|
print(" {command}".format(command=' '.join(command)))
|
||||||
command = [sys.executable, "-c", "import %s" % test_name]
|
|
||||||
print(" Import test command: `%s`." % (' '.join(command),))
|
|
||||||
print()
|
print()
|
||||||
|
try:
|
||||||
subprocess.check_call(command)
|
subprocess.check_call(command)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
print()
|
print()
|
||||||
@@ -434,7 +434,7 @@ class Runner(DiscoverRunner):
|
|||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
print()
|
print()
|
||||||
print(" This is often caused by a test module/class/function that doesn't exist or ")
|
print(" This is often caused by a test module/class/function that doesn't exist or ")
|
||||||
print(" import properly. You can usually debug in a `manage.py shell` via e.g. ")
|
print(" import properly. You can usually debug in a `./manage.py shell` via e.g. ")
|
||||||
print(" import zerver.tests.test_messages")
|
print(" import zerver.tests.test_messages")
|
||||||
print(" from zerver.tests.test_messages import StreamMessagesTest")
|
print(" from zerver.tests.test_messages import StreamMessagesTest")
|
||||||
print(" StreamMessagesTest.test_message_to_stream")
|
print(" StreamMessagesTest.test_message_to_stream")
|
||||||
|
|||||||
Reference in New Issue
Block a user