summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lasher <chris.lasher@gmail.com>2013-01-18 14:36:18 -0500
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2013-03-04 23:26:31 +0100
commit3c011a3c6e97e40410ad88a734605759fb247301 (patch)
treed86a52ec2f92294ccb59a0e39bc34b96fd8e557c
parentbe403fd5a109af49d228ab620ab14d04cb9e34c8 (diff)
downloadfactory-boy-3c011a3c6e97e40410ad88a734605759fb247301.tar
factory-boy-3c011a3c6e97e40410ad88a734605759fb247301.tar.gz
Let mock source be chosen by Python major version.
This should provide better Python 3 compatibility, since mock is in the Python 3 standard library as unittest.mock. Conflicts: tests/test_declarations.py Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
-rw-r--r--tests/compat.py6
-rw-r--r--tests/test_declarations.py6
2 files changed, 8 insertions, 4 deletions
diff --git a/tests/compat.py b/tests/compat.py
index 8d4f1d0..769ffd4 100644
--- a/tests/compat.py
+++ b/tests/compat.py
@@ -29,3 +29,9 @@ try:
import unittest2 as unittest
except ImportError:
import unittest
+
+if is_python2:
+ import mock
+else:
+ from unittest import mock
+
diff --git a/tests/test_declarations.py b/tests/test_declarations.py
index 59a3955..93e11d0 100644
--- a/tests/test_declarations.py
+++ b/tests/test_declarations.py
@@ -24,11 +24,9 @@ import datetime
import itertools
import warnings
-from mock import MagicMock
-
from factory import declarations
-from .compat import unittest
+from .compat import mock, unittest
from . import tools
@@ -299,7 +297,7 @@ class RelatedFactoryTestCase(unittest.TestCase):
class PostGenerationMethodCallTestCase(unittest.TestCase):
def setUp(self):
- self.obj = MagicMock()
+ self.obj = mock.MagicMock()
def test_simplest_setup_and_call(self):
decl = declarations.PostGenerationMethodCall('method')