aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polyconseil.fr>2015-04-27 15:30:14 +0200
committerRaphaël Barrois <raphael.barrois@polyconseil.fr>2015-04-27 15:30:14 +0200
commit526293fccdc2661d6b0d68e524dc32aa858a3435 (patch)
treeb9857377d3ae7dfe1c5a4cdc3a5c40d747bbd5cc
parentbb7939b061f468f977caba8e5fdaaff62096e7ac (diff)
downloadfactory-boy-526293fccdc2661d6b0d68e524dc32aa858a3435.tar
factory-boy-526293fccdc2661d6b0d68e524dc32aa858a3435.tar.gz
Fix test startup for Django==1.6
-rw-r--r--tests/__init__.py4
-rw-r--r--tests/test_django.py40
2 files changed, 24 insertions, 20 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index c73165f..dc1a119 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,10 +1,12 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2011-2015 Raphaël Barrois
+# factory.django needs a configured Django.
+from .test_django import *
+
from .test_base import *
from .test_containers import *
from .test_declarations import *
-from .test_django import *
from .test_fuzzy import *
from .test_helpers import *
from .test_using import *
diff --git a/tests/test_django.py b/tests/test_django.py
index 33d159d..2cfb55c 100644
--- a/tests/test_django.py
+++ b/tests/test_django.py
@@ -22,31 +22,13 @@
import os
-import factory
-import factory.django
-
try:
import django
except ImportError: # pragma: no cover
django = None
-try:
- from PIL import Image
-except ImportError: # pragma: no cover
- # Try PIL alternate name
- try:
- import Image
- except ImportError:
- # OK, not installed
- Image = None
-
-
-from .compat import is_python2, unittest, mock
-from . import testdata
-from . import tools
-
-
+# Setup Django as soon as possible
if django is not None:
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tests.djapp.settings')
@@ -67,6 +49,26 @@ else:
django_test = unittest
+
+try:
+ from PIL import Image
+except ImportError: # pragma: no cover
+ # Try PIL alternate name
+ try:
+ import Image
+ except ImportError:
+ # OK, not installed
+ Image = None
+
+
+import factory
+import factory.django
+
+from .compat import is_python2, unittest, mock
+from . import testdata
+from . import tools
+
+
test_state = {}