diff options
author | Tim Graham <timograham@gmail.com> | 2015-01-17 21:04:07 -0500 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2015-01-18 12:51:15 -0500 |
commit | d029fafea1a1f2f257397fbcd0fa3b531e09854f (patch) | |
tree | 1907d7b92dc7f17f07e8624469439bbab575eb8a /tests/utils_tests | |
parent | c3336e7e4f146fc62272d462288a00f8d78c1f83 (diff) | |
download | django-d029fafea1a1f2f257397fbcd0fa3b531e09854f.tar.gz |
Removed utils.module_loading.import_by_path() per deprecation timeline; refs #21674.
Diffstat (limited to 'tests/utils_tests')
-rw-r--r-- | tests/utils_tests/test_module_loading.py | 40 |
1 files changed, 2 insertions, 38 deletions
diff --git a/tests/utils_tests/test_module_loading.py b/tests/utils_tests/test_module_loading.py index 89c9d03b9e..2addc2649a 100644 --- a/tests/utils_tests/test_module_loading.py +++ b/tests/utils_tests/test_module_loading.py @@ -3,15 +3,12 @@ from importlib import import_module import os import sys import unittest -import warnings from zipimport import zipimporter -from django.core.exceptions import ImproperlyConfigured -from django.test import SimpleTestCase, ignore_warnings, modify_settings +from django.test import SimpleTestCase, modify_settings from django.test.utils import extend_sys_path from django.utils import six -from django.utils.deprecation import RemovedInDjango19Warning -from django.utils.module_loading import (autodiscover_modules, import_by_path, import_string, +from django.utils.module_loading import (autodiscover_modules, import_string, module_has_submodule) from django.utils._os import upath @@ -110,39 +107,7 @@ class EggLoader(unittest.TestCase): self.assertRaises(ImportError, import_module, 'egg_module.sub1.sub2.no_such_module') -@ignore_warnings(category=RemovedInDjango19Warning) class ModuleImportTestCase(unittest.TestCase): - def test_import_by_path(self): - cls = import_by_path('django.utils.module_loading.import_by_path') - self.assertEqual(cls, import_by_path) - - # Test exceptions raised - for path in ('no_dots_in_path', 'unexistent.path', 'utils_tests.unexistent'): - self.assertRaises(ImproperlyConfigured, import_by_path, path) - - with self.assertRaises(ImproperlyConfigured) as cm: - 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.') - - def test_import_by_path_pending_deprecation_warning(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter('always', category=RemovedInDjango19Warning) - cls = import_by_path('django.utils.module_loading.import_by_path') - self.assertEqual(cls, import_by_path) - self.assertEqual(len(w), 1) - self.assertTrue(issubclass(w[-1].category, RemovedInDjango19Warning)) - self.assertIn('deprecated', str(w[-1].message)) - def test_import_string(self): cls = import_string('django.utils.module_loading.import_string') self.assertEqual(cls, import_string) @@ -150,7 +115,6 @@ class ModuleImportTestCase(unittest.TestCase): # Test exceptions raised self.assertRaises(ImportError, import_string, 'no_dots_in_path') self.assertRaises(ImportError, import_string, 'utils_tests.unexistent') - self.assertRaises(ImportError, import_string, 'unexistent.path') @modify_settings(INSTALLED_APPS={'append': 'utils_tests.test_module'}) |