Blame use-standard-library-mock-when-available.patch

4a68c1b
From a027deb1e41ceedd269507ab938ee05f5113290d Mon Sep 17 00:00:00 2001
4a68c1b
From: Carl George <carl@george.computer>
4a68c1b
Date: Sat, 13 Oct 2018 17:25:09 -0500
4a68c1b
Subject: [PATCH] Use standard library mock when available
4a68c1b
4a68c1b
---
4a68c1b
 multipart/tests/test_multipart.py |  5 ++++-
4a68c1b
 setup.py                          | 16 ++++++++++------
4a68c1b
 2 files changed, 14 insertions(+), 7 deletions(-)
4a68c1b
4a68c1b
diff --git a/multipart/tests/test_multipart.py b/multipart/tests/test_multipart.py
4a68c1b
index dbb7ff1..decf794 100644
4a68c1b
--- a/multipart/tests/test_multipart.py
4a68c1b
+++ b/multipart/tests/test_multipart.py
4a68c1b
@@ -16,7 +16,10 @@
4a68c1b
 from io import BytesIO
4a68c1b
 from six import binary_type, text_type
4a68c1b
 
4a68c1b
-from mock import MagicMock, Mock, patch
4a68c1b
+try:
4a68c1b
+    from unittest.mock import MagicMock, Mock, patch
4a68c1b
+except ImportError:
4a68c1b
+    from mock import MagicMock, Mock, patch
4a68c1b
 
4a68c1b
 from ..multipart import *
4a68c1b
 
4a68c1b
diff --git a/setup.py b/setup.py
4a68c1b
index 821d337..8e90309 100755
4a68c1b
--- a/setup.py
4a68c1b
+++ b/setup.py
4a68c1b
@@ -16,6 +16,15 @@
4a68c1b
 version_re = re.compile(r'((?:\d+)\.(?:\d+)\.(?:\d+))')
4a68c1b
 version = version_re.search(version_data).group(0)
4a68c1b
 
4a68c1b
+tests_require = [
4a68c1b
+    'pytest',
4a68c1b
+    'pytest-cov',
4a68c1b
+    'PyYAML'
4a68c1b
+]
4a68c1b
+
4a68c1b
+if sys.version_info[0:2] < (3, 3):
4a68c1b
+    tests_require.append('mock')
4a68c1b
+
4a68c1b
 setup(name='python-multipart',
4a68c1b
       version=version,
4a68c1b
       description='A streaming multipart parser for Python',
4a68c1b
@@ -27,12 +36,7 @@
4a68c1b
       install_requires=[
4a68c1b
           'six>=1.4.0',
4a68c1b
       ],
4a68c1b
-      tests_require=[
4a68c1b
-          'pytest',
4a68c1b
-          'pytest-cov',
4a68c1b
-          'Mock',
4a68c1b
-          'PyYAML'
4a68c1b
-      ],
4a68c1b
+      tests_require=tests_require,
4a68c1b
       packages=[
4a68c1b
           'multipart',
4a68c1b
           'multipart.tests',