summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hrivnak <mhrivnak@hrivnak.org>2014-03-08 01:44:53 -0500
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2014-03-16 20:23:37 +0100
commit5688677a89f6d8f0168290ca069e473c15b7617c (patch)
tree1669d6c7e586b2c4a2cc3a9d234b648c1b344b8c
parentb37206c0155ffa0d853d9a38fc5b9ba3ba4c8b73 (diff)
downloadsemantic-version-5688677a89f6d8f0168290ca069e473c15b7617c.tar.gz
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.
-rw-r--r--CREDITS1
-rw-r--r--tests/django_test_app/__init__.py24
-rw-r--r--tests/test_django.py12
3 files changed, 25 insertions, 12 deletions
diff --git a/CREDITS b/CREDITS
index 0eb13f0..75f8e2e 100644
--- a/CREDITS
+++ b/CREDITS
@@ -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
diff --git a/tests/django_test_app/__init__.py b/tests/django_test_app/__init__.py
index e69de29..1c692b0 100644
--- a/tests/django_test_app/__init__.py
+++ b/tests/django_test_app/__init__.py
@@ -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',
+ ]
+ )
diff --git a/tests/test_django.py b/tests/test_django.py
index 0cb480b..35193fa 100644
--- a/tests/test_django.py
+++ b/tests/test_django.py
@@ -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