summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBouke Haarsma <bouke@webatoom.nl>2013-11-20 18:50:36 +0100
committerClaude Paroz <claude@2xlibre.net>2013-11-22 20:37:09 +0100
commitd55df0b81083d8aa02145ac5885a855a9c9577b3 (patch)
tree6cafd66edd258046618da04b945a83ea1baa72ec /tests
parentea0d97c470ca2d5ddb4320fe03c77221b3064adf (diff)
[1.6.x] Fixed #21443 -- Cannot show debug info on PY3's importlib
Thanks productions@zaziork.co.uk for the review. Backport of 18185724e6 from master.
Diffstat (limited to 'tests')
-rw-r--r--tests/view_tests/tests/test_debug.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
index 1ea078bad3..b336e16e48 100644
--- a/tests/view_tests/tests/test_debug.py
+++ b/tests/view_tests/tests/test_debug.py
@@ -17,6 +17,7 @@ from django.test import TestCase, RequestFactory
from django.test.utils import (override_settings, setup_test_template_loader,
restore_template_loaders)
from django.utils.encoding import force_text, force_bytes
+from django.utils import importlib, six
from django.views.debug import ExceptionReporter
from .. import BrokenException, except_args
@@ -223,6 +224,21 @@ class ExceptionReporterTests(TestCase):
self.assertIn('<h2>Request information</h2>', html)
self.assertIn('<p>Request data not supplied</p>', html)
+ @skipIf(six.PY2, 'Bug manifests on PY3 only')
+ def test_unfrozen_importlib(self):
+ """
+ importlib is not a frozen app, but its loader thinks it's frozen which
+ results in an ImportError on Python 3. Refs #21443.
+ """
+ try:
+ request = self.rf.get('/test_view/')
+ importlib.import_module('abc.def.invalid.name')
+ except Exception:
+ exc_type, exc_value, tb = sys.exc_info()
+ reporter = ExceptionReporter(request, exc_type, exc_value, tb)
+ html = reporter.get_traceback_html()
+ self.assertIn('<h1>ImportError at /test_view/</h1>', html)
+
class PlainTextReportTests(TestCase):
rf = RequestFactory()