From 16202863facc8629a7422cf74cd3df30142d3aaf Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 15 Sep 2016 11:54:22 -0400 Subject: [PATCH] Refs #27025 -- Fixed tests for the new ModuleNotFoundError in Python 3.6. http://bugs.python.org/issue15767 --- tests/admin_scripts/tests.py | 3 ++- tests/view_tests/tests/test_debug.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index 5ac24db6ea..567a8f14f8 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -34,6 +34,7 @@ from django.utils.six import PY2, PY3, StringIO custom_templates_dir = os.path.join(os.path.dirname(upath(__file__)), 'custom_templates') +PY36 = sys.version_info >= (3, 6) SYSTEM_CHECK_MSG = 'System check identified no issues' @@ -1166,7 +1167,7 @@ class ManageCheck(AdminScriptTestCase): args = ['check'] out, err = self.run_manage(args) self.assertNoOutput(out) - self.assertOutput(err, 'ImportError') + self.assertOutput(err, 'ModuleNotFoundError' if PY36 else 'ImportError') self.assertOutput(err, 'No module named') self.assertOutput(err, 'admin_scriptz') diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py index 7a450306f5..ba6e6defee 100644 --- a/tests/view_tests/tests/test_debug.py +++ b/tests/view_tests/tests/test_debug.py @@ -36,6 +36,8 @@ from ..views import ( if six.PY3: from .py3_test_debug import Py3ExceptionReporterTests # NOQA +PY36 = sys.version_info >= (3, 6) + class User(object): def __str__(self): @@ -430,7 +432,7 @@ class ExceptionReporterTests(SimpleTestCase): exc_type, exc_value, tb = sys.exc_info() reporter = ExceptionReporter(request, exc_type, exc_value, tb) html = reporter.get_traceback_html() - self.assertIn('

ImportError at /test_view/

', html) + self.assertIn('

%sError at /test_view/

' % 'ModuleNotFound' if PY36 else 'Import', html) def test_ignore_traceback_evaluation_exceptions(self): """