!39 [sync] PR-37: Since Python 3.3, mock is part of unittest in the standard library
From: @openeuler-sync-bot Reviewed-by: @Charlie_li Signed-off-by: @Charlie_li
This commit is contained in:
commit
bbc9bb5b5e
93
Use-mock-from-the-standard-library.patch
Normal file
93
Use-mock-from-the-standard-library.patch
Normal file
@ -0,0 +1,93 @@
|
||||
From f88fe0a1142f71215fea95be9900eaecb546f7b5 Mon Sep 17 00:00:00 2001
|
||||
From: Pavel Cahyna <pcahyna@redhat.com>
|
||||
Date: Wed, 3 Mar 2021 22:07:25 +0100
|
||||
Subject: [PATCH] Use mock from the standard library
|
||||
|
||||
Since Python 3.3, mock is part of unittest in the standard library.
|
||||
|
||||
Provide compatibility for older versions, since httplib2 seems to still
|
||||
support Python2.
|
||||
---
|
||||
requirements-test.txt | 2 +-
|
||||
tests/test_cacerts_from_env.py | 5 ++++-
|
||||
tests/test_http.py | 5 ++++-
|
||||
tests/test_other.py | 5 ++++-
|
||||
tests/test_proxy.py | 5 ++++-
|
||||
5 files changed, 17 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/requirements-test.txt b/requirements-test.txt
|
||||
index d208a8f..623875e 100644
|
||||
--- a/requirements-test.txt
|
||||
+++ b/requirements-test.txt
|
||||
@@ -1,6 +1,6 @@
|
||||
flake8==3.4.1
|
||||
future==0.16.0
|
||||
-mock==2.0.0
|
||||
+mock==2.0.0;python_version<"3.3"
|
||||
pytest-cov==2.5.1
|
||||
pytest-forked==0.2
|
||||
pytest-randomly==1.2.1
|
||||
diff --git a/tests/test_cacerts_from_env.py b/tests/test_cacerts_from_env.py
|
||||
index cb2bd9f..f04ba0e 100644
|
||||
--- a/tests/test_cacerts_from_env.py
|
||||
+++ b/tests/test_cacerts_from_env.py
|
||||
@@ -1,6 +1,9 @@
|
||||
import os
|
||||
import sys
|
||||
-import mock
|
||||
+try:
|
||||
+ from unittest import mock
|
||||
+except ImportError:
|
||||
+ import mock
|
||||
import pytest
|
||||
import tempfile
|
||||
import httplib2
|
||||
diff --git a/tests/test_http.py b/tests/test_http.py
|
||||
index f61992c..65bac01 100644
|
||||
--- a/tests/test_http.py
|
||||
+++ b/tests/test_http.py
|
||||
@@ -5,7 +5,10 @@ from __future__ import print_function
|
||||
import email.utils
|
||||
import errno
|
||||
import httplib2
|
||||
-import mock
|
||||
+try:
|
||||
+ from unittest import mock
|
||||
+except ImportError:
|
||||
+ import mock
|
||||
import os
|
||||
import pytest
|
||||
from six.moves import http_client, urllib
|
||||
diff --git a/tests/test_other.py b/tests/test_other.py
|
||||
index 0f450ab..6b902b9 100644
|
||||
--- a/tests/test_other.py
|
||||
+++ b/tests/test_other.py
|
||||
@@ -1,5 +1,8 @@
|
||||
import httplib2
|
||||
-import mock
|
||||
+try:
|
||||
+ from unittest import mock
|
||||
+except ImportError:
|
||||
+ import mock
|
||||
import os
|
||||
import pickle
|
||||
import pytest
|
||||
diff --git a/tests/test_proxy.py b/tests/test_proxy.py
|
||||
index edafe01..556b448 100644
|
||||
--- a/tests/test_proxy.py
|
||||
+++ b/tests/test_proxy.py
|
||||
@@ -9,7 +9,10 @@ from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import httplib2
|
||||
-import mock
|
||||
+try:
|
||||
+ from unittest import mock
|
||||
+except ImportError:
|
||||
+ import mock
|
||||
import os
|
||||
import pytest
|
||||
import socket
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
Name: python-httplib2
|
||||
Version: 0.19.0
|
||||
Release: 4
|
||||
Release: 5
|
||||
Summary: Small, fast HTTP client library for Python.
|
||||
License: MIT
|
||||
URL: https://github.com/httplib2/httplib2
|
||||
Source0: https://files.pythonhosted.org/packages/ed/ef/f0e05d5886a9c25dea4b18be06cd7bcaddbae0168cc576f3568f9bd6a35a/httplib2-0.19.0.tar.gz
|
||||
Patch0: 0001-cancel-require-pyparsing-version-limit.patch
|
||||
Patch1: Use-mock-from-the-standard-library.patch
|
||||
%if 0%{?with_python3}
|
||||
BuildRequires: python3-setuptools python3-devel
|
||||
%endif
|
||||
@ -56,6 +57,9 @@ popd
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Thu Dec 28 fandehui <fandehui@xfusion.com> - 0.19.0-5
|
||||
- Use mock from the standard library
|
||||
|
||||
* Mon Jan 9 2022 baizhonggui <baizhonggui@huawei.com> - 0.19.0-4
|
||||
- support newst pyparsing syntax
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user