From 3c011a3c6e97e40410ad88a734605759fb247301 Mon Sep 17 00:00:00 2001 From: Chris Lasher Date: Fri, 18 Jan 2013 14:36:18 -0500 Subject: Let mock source be chosen by Python major version. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tests/compat.py | 6 ++++++ tests/test_declarations.py | 6 ++---- 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') -- cgit v1.2.3