summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polyconseil.fr>2012-04-13 17:52:08 +0200
committerRaphaël Barrois <raphael.barrois@polyconseil.fr>2012-04-15 10:06:39 +0200
commit03c92201e34cea40b494c4aefb324af100c181ea (patch)
tree1172dc59532035b9e7769321293a838de6a2a81a /tests
parent3ba8ed544fa9e866f97efc41155ee296f022e9b4 (diff)
downloadfactory-boy-03c92201e34cea40b494c4aefb324af100c181ea.tar
factory-boy-03c92201e34cea40b494c4aefb324af100c181ea.tar.gz
Make tests compatible with python2.6 + unittest2
Signed-off-by: Raphaël Barrois <raphael.barrois@polyconseil.fr>
Diffstat (limited to 'tests')
-rw-r--r--tests/compat.py27
-rw-r--r--tests/test_base.py7
-rw-r--r--tests/test_containers.py7
-rw-r--r--tests/test_declarations.py6
-rw-r--r--tests/test_using.py5
-rw-r--r--tests/test_utils.py6
6 files changed, 35 insertions, 23 deletions
diff --git a/tests/compat.py b/tests/compat.py
new file mode 100644
index 0000000..15fa3ae
--- /dev/null
+++ b/tests/compat.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2011 Raphaël Barrois
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+"""Compatibility tools for tests"""
+
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
diff --git a/tests/test_base.py b/tests/test_base.py
index 0788f82..e0a6547 100644
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -20,16 +20,13 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
-try:
- import unittest2 as unittest
-except ImportError:
- import unittest
-
import warnings
from factory import base
from factory import declarations
+from .compat import unittest
+
class TestObject(object):
def __init__(self, one=None, two=None, three=None, four=None):
self.one = one
diff --git a/tests/test_containers.py b/tests/test_containers.py
index a2a369d..55fe576 100644
--- a/tests/test_containers.py
+++ b/tests/test_containers.py
@@ -20,15 +20,12 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
-try:
- import unittest2 as unittest
-except ImportError:
- import unittest
-
from factory import base
from factory import containers
from factory import declarations
+from .compat import unittest
+
class LazyStubTestCase(unittest.TestCase):
def test_basic(self):
stub = containers.LazyStub({'one': 1, 'two': 2})
diff --git a/tests/test_declarations.py b/tests/test_declarations.py
index 3960670..f15645f 100644
--- a/tests/test_declarations.py
+++ b/tests/test_declarations.py
@@ -20,13 +20,11 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
-try:
- import unittest2 as unittest
-except ImportError:
- import unittest
from factory.declarations import deepgetattr, OrderedDeclaration, Sequence
+from .compat import unittest
+
class OrderedDeclarationTestCase(unittest.TestCase):
def test_errors(self):
decl = OrderedDeclaration()
diff --git a/tests/test_using.py b/tests/test_using.py
index fcd3aab..a3cf89c 100644
--- a/tests/test_using.py
+++ b/tests/test_using.py
@@ -20,13 +20,10 @@
# THE SOFTWARE.
"""Tests using factory."""
-try:
- import unittest2 as unittest
-except ImportError:
- import unittest
import factory
+from .compat import unittest
class TestObject(object):
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 2c77c15..6fd6ee2 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -21,13 +21,9 @@
# THE SOFTWARE.
-try:
- import unittest2 as unittest
-except ImportError:
- import unittest
-
from factory import utils
+from .compat import unittest
class DecLengthCompareTestCase(unittest.TestCase):
def test_reciprocity(self):