瀏覽代碼

Refs #23919 -- Removed an obsolete test for a Python 2 code path (refs #15662).

Fixed #21628 by removing the last usage of the imp module.
Tim Graham 8 年之前
父節點
當前提交
9e9e73735e
共有 1 個文件被更改,包括 0 次插入35 次删除
  1. 0 35
      tests/utils_tests/test_module_loading.py

+ 0 - 35
tests/utils_tests/test_module_loading.py

@@ -1,4 +1,3 @@
-import imp
 import os
 import sys
 import unittest
@@ -13,11 +12,6 @@ from django.utils.module_loading import (
 
 
 class DefaultLoader(unittest.TestCase):
-    def setUp(self):
-        sys.meta_path.insert(0, ProxyFinder())
-
-    def tearDown(self):
-        sys.meta_path.pop(0)
 
     def test_loader(self):
         "Normal module existence can be tested"
@@ -178,35 +172,6 @@ class AutodiscoverModulesTestCase(SimpleTestCase):
         self.assertEqual(site._registry, {'lorem': 'ipsum'})
 
 
-class ProxyFinder:
-    def __init__(self):
-        self._cache = {}
-
-    def find_module(self, fullname, path=None):
-        tail = fullname.rsplit('.', 1)[-1]
-        try:
-            fd, fn, info = imp.find_module(tail, path)
-            if fullname in self._cache:
-                old_fd = self._cache[fullname][0]
-                if old_fd:
-                    old_fd.close()
-            self._cache[fullname] = (fd, fn, info)
-        except ImportError:
-            return None
-        else:
-            return self  # this is a loader as well
-
-    def load_module(self, fullname):
-        if fullname in sys.modules:
-            return sys.modules[fullname]
-        fd, fn, info = self._cache[fullname]
-        try:
-            return imp.load_module(fullname, fd, fn, info)
-        finally:
-            if fd:
-                fd.close()
-
-
 class TestFinder:
     def __init__(self, *args, **kwargs):
         self.importer = zipimporter(*args, **kwargs)