* Use stdlib unittest.mock.
- Drop {Build,}Requires on mock.
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-before-after?expand=0&rev=4
42 lines
1.3 KiB
Diff
42 lines
1.3 KiB
Diff
From 11c0ecc7e8a2f90a762831e216c1bc40abfda43a Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
|
|
Date: Mon, 10 May 2021 22:01:00 +0200
|
|
Subject: [PATCH] Use built-in unittest.mock in Python 3.3+
|
|
|
|
---
|
|
before_after/__init__.py | 5 ++++-
|
|
setup.py | 3 ++-
|
|
2 files changed, 6 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/before_after/__init__.py b/before_after/__init__.py
|
|
index 1081684..e713a61 100644
|
|
--- a/before_after/__init__.py
|
|
+++ b/before_after/__init__.py
|
|
@@ -50,7 +50,10 @@ def inner(*a, **k):
|
|
return ret
|
|
return inner
|
|
|
|
- from mock import patch
|
|
+ if sys.version_info >= (3, 3):
|
|
+ from unittest.mock import patch
|
|
+ else:
|
|
+ from mock import patch
|
|
|
|
patcher = patch(target, **kwargs)
|
|
original, _ = patcher.get_original()
|
|
diff --git a/setup.py b/setup.py
|
|
index 572470c..b1167df 100644
|
|
--- a/setup.py
|
|
+++ b/setup.py
|
|
@@ -31,8 +31,9 @@
|
|
'Natural Language :: English',
|
|
'Operating System :: OS Independent',
|
|
'Programming Language :: Python :: 2.7',
|
|
+ 'Programming Language :: Python :: 3',
|
|
],
|
|
keywords=['testing', 'race conditions'],
|
|
|
|
- install_requires=['mock>=1.0.1'],
|
|
+ install_requires=['mock>=1.0.1; python_version < "3.3"'],
|
|
)
|