moved django test app settings to the django test app module

... to guarantee the settings get executed before any code in that app. Since
python's unittest.TestLoader does not guarantee in what order it will import
modules while hunting for test cases, the unit tests could fail to even load if
tests.django_test_app.models was loaded before tests.test_django. This failure
was seen on ARM machines, which happened to traverse the module tree in an
inconvenient order.
This commit is contained in:
Michael Hrivnak
2014-03-08 01:44:53 -05:00
committed by Raphaël Barrois
parent b37206c015
commit 5688677a89
3 changed files with 25 additions and 12 deletions

View File

@@ -18,6 +18,7 @@ Contributors
The project has received contributions from (in alphabetical order):
* Raphaël Barrois <raphael.barrois+semver@polytechnique.org> (https://github.com/rbarrois)
* Michael Hrivnak <mhrivnak@hrivnak.org> (https://github.com/mhrivnak)
Contributor license agreement

View File

@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2012-2014 The python-semanticversion project
# This code is distributed under the two-clause BSD License.
try: # pragma: no cover
from django.conf import settings
django_loaded = True
except ImportError: # pragma: no cover
django_loaded = False
if django_loaded: # pragma: no cover
if not settings.configured:
settings.configure(
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'tests/db/test.sqlite',
}
},
INSTALLED_APPS=[
'tests.django_test_app',
]
)

View File

@@ -18,18 +18,6 @@ except ImportError: # pragma: no cover
django_loaded = False
if django_loaded: # pragma: no cover
if not settings.configured:
settings.configure(
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'tests/db/test.sqlite',
}
},
INSTALLED_APPS=[
'tests.django_test_app',
]
)
from .django_test_app import models
from django.core import serializers