mirror of
https://github.com/django/django.git
synced 2025-07-05 02:09:13 +00:00
[gsoc2009-testing] Use importlib from django.util in attempt_import
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/test-improvements@11136 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
8639d7e2d3
commit
833b2334bc
@ -6,19 +6,19 @@ from time import sleep
|
|||||||
import types
|
import types
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
|
from django.utils import importlib
|
||||||
class ServerContainer(object):
|
class ServerContainer(object):
|
||||||
start_test_server = djangotest.start_test_server
|
start_test_server = djangotest.start_test_server
|
||||||
stop_test_server = djangotest.stop_test_server
|
stop_test_server = djangotest.stop_test_server
|
||||||
|
|
||||||
def attempt_import(name, suffix):
|
def attempt_import(name, suffix):
|
||||||
try:
|
try:
|
||||||
mod = __import__(name+'.'+suffix)
|
mod = importlib.import_module(name+'.'+suffix)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
mod = None
|
mod = None
|
||||||
if mod is not None:
|
if mod is not None:
|
||||||
s = name.split('.')
|
s = name.split('.')
|
||||||
mod = __import__(s.pop(0))
|
mod = importlib.import_module(s.pop(0))
|
||||||
for x in s+[suffix]:
|
for x in s+[suffix]:
|
||||||
try:
|
try:
|
||||||
mod = getattr(mod, x)
|
mod = getattr(mod, x)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user