Kaydet (Commit) 9e9e7373 authored tarafından Tim Graham's avatar Tim Graham Kaydeden (comit) GitHub

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.
üst b09faa49
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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment