[1.11.x] Fixed db backend discovery in admin_scripts tests.

Not all backends have dots in them.

Backport of 60f5129076 from master
This commit is contained in:
Florian Apolloner 2017-05-10 15:47:20 +02:00 committed by Tim Graham
parent 03d0c05fdf
commit cf81add997
1 changed files with 3 additions and 4 deletions

View File

@ -120,11 +120,10 @@ class AdminScriptTestCase(unittest.TestCase):
Returns the paths for any external backend packages.
"""
paths = []
first_package_re = re.compile(r'(^[^\.]+)\.')
for backend in settings.DATABASES.values():
result = first_package_re.findall(backend['ENGINE'])
if result and result != ['django']:
backend_pkg = __import__(result[0])
package = backend['ENGINE'].split('.')[0]
if package != 'django':
backend_pkg = __import__(package)
backend_dir = os.path.dirname(backend_pkg.__file__)
paths.append(os.path.dirname(backend_dir))
return paths