mirror of
https://github.com/django/django.git
synced 2025-07-24 13:44:32 +00:00
Fixed #20167 -- Preserve the traceback of ImportError
s in import_by_path
.
Thanks @carljm for the review.
This commit is contained in:
parent
3ff3212713
commit
2d0db67813
2 changed files with 15 additions and 2 deletions
|
@ -120,6 +120,16 @@ class ModuleImportTestCase(unittest.TestCase):
|
|||
import_by_path('unexistent.module.path', error_prefix="Foo")
|
||||
self.assertTrue(str(cm.exception).startswith('Foo'))
|
||||
|
||||
def test_import_error_traceback(self):
|
||||
"""Test preserving the original traceback on an ImportError."""
|
||||
try:
|
||||
import_by_path('test_module.bad_module.content')
|
||||
except ImproperlyConfigured:
|
||||
traceback = sys.exc_info()[2]
|
||||
|
||||
self.assertIsNotNone(traceback.tb_next.tb_next,
|
||||
'Should have more than the calling frame in the traceback.')
|
||||
|
||||
|
||||
class ProxyFinder(object):
|
||||
def __init__(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue