From 526293fccdc2661d6b0d68e524dc32aa858a3435 Mon Sep 17 00:00:00 2001 From: Raphaël Barrois Date: Mon, 27 Apr 2015 15:30:14 +0200 Subject: Fix test startup for Django==1.6 --- tests/__init__.py | 4 +++- tests/test_django.py | 40 +++++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 20 deletions(-) (limited to 'tests') 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 = {} -- cgit v1.2.3