mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +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.
 | 
			
		||||
 | 
			
		||||
def print_error_message(test_name: Text) -> None:
 | 
			
		||||
    command = [sys.executable, "-c", "import %s" % test_name]
 | 
			
		||||
    print()
 | 
			
		||||
    print("Actual test to be run is %s, but import failed." % (test_name,))
 | 
			
		||||
    print("  Importing test module directly to generate clearer traceback.")
 | 
			
		||||
    try:
 | 
			
		||||
        command = [sys.executable, "-c", "import %s" % test_name]
 | 
			
		||||
        print("  Import test command: `%s`." % (' '.join(command),))
 | 
			
		||||
    print("Importing test module directly to generate clearer traceback:")
 | 
			
		||||
    print("  {command}".format(command=' '.join(command)))
 | 
			
		||||
    print()
 | 
			
		||||
    try:
 | 
			
		||||
        subprocess.check_call(command)
 | 
			
		||||
    except subprocess.CalledProcessError:
 | 
			
		||||
        print()
 | 
			
		||||
@@ -434,7 +434,7 @@ class Runner(DiscoverRunner):
 | 
			
		||||
            traceback.print_exc()
 | 
			
		||||
            print()
 | 
			
		||||
            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("    from zerver.tests.test_messages import StreamMessagesTest")
 | 
			
		||||
            print("    StreamMessagesTest.test_message_to_stream")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user