Support old Python 2.7 releases (#341)

Signed-off-by: zhang-liang-pengkun <zhangliangpengkun@xfusion.com>
This commit is contained in:
zhang-liang-pengkun 2023-12-22 16:39:13 +08:00
parent 9994f95939
commit 69d4152c9b
2 changed files with 58 additions and 1 deletions

View File

@ -0,0 +1,53 @@
From 7bd9afea1ee20aa33622aedf0f3a5375036fbabf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Thu, 9 Aug 2018 22:40:55 +0200
Subject: [PATCH] Support old Python 2.7 releases (#341)
See https://github.com/gabrielfalcao/HTTPretty/issues/337#issuecomment-395481459https://github.com/gabrielfalcao/HTTPretty/issues/337#issuecomment-395481459
---
httpretty/core.py | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/httpretty/core.py b/httpretty/core.py
index 6e89634..92dd8a9 100644
--- a/httpretty/core.py
+++ b/httpretty/core.py
@@ -99,7 +99,10 @@ except ImportError:
try: # pragma: no cover
import ssl
old_ssl_wrap_socket = ssl.wrap_socket
- old_sslcontext_wrap_socket = ssl.SSLContext.wrap_socket
+ try:
+ old_sslcontext_wrap_socket = ssl.SSLContext.wrap_socket
+ except AttributeError:
+ pass
if not PY3:
old_sslwrap_simple = ssl.sslwrap_simple
old_sslsocket = ssl.SSLSocket
@@ -1397,7 +1400,10 @@ class httpretty(HttpBaseClass):
if ssl:
ssl.wrap_socket = old_ssl_wrap_socket
ssl.SSLSocket = old_sslsocket
- ssl.SSLContext.wrap_socket = old_sslcontext_wrap_socket
+ try:
+ ssl.SSLContext.wrap_socket = old_sslcontext_wrap_socket
+ except AttributeError:
+ pass
ssl.__dict__['wrap_socket'] = old_ssl_wrap_socket
ssl.__dict__['SSLSocket'] = old_sslsocket
@@ -1488,7 +1494,10 @@ class httpretty(HttpBaseClass):
new_wrap = partial(fake_wrap_socket, old_ssl_wrap_socket)
ssl.wrap_socket = new_wrap
ssl.SSLSocket = FakeSSLSocket
- ssl.SSLContext.wrap_socket = partial(fake_wrap_socket, old_sslcontext_wrap_socket)
+ try:
+ ssl.SSLContext.wrap_socket = partial(fake_wrap_socket, old_sslcontext_wrap_socket)
+ except AttributeError:
+ pass
ssl.__dict__['wrap_socket'] = new_wrap
ssl.__dict__['SSLSocket'] = FakeSSLSocket
--
2.39.0.windows.2

View File

@ -1,6 +1,6 @@
Name: python-httpretty
Version: 0.9.5
Release: 6
Release: 7
Summary: HTTP Client mocking tool for Python
License: MIT
URL: https://pypi.org/project/httpretty/
@ -11,6 +11,7 @@ Patch0002: 0001-Handle-bugs-in-older-urllib3-versions-in-one-of-the-.patch
Patch0003: 0001-Call-reset-from-setUp-and-tearDown-in-addition-to-en.patch
Patch0004: Mock-time-to-make-date-based-tests-reliable.patch
Patch0005: 0002-fix-query-param-matching.patch
Patch0006: 0003-Support-old-Python-2.7-releases-341.patch
BuildRequires: python2-devel python2-setuptools python2-httplib2 python2-mock python2-nose
BuildRequires: python2-requests python2-sure python2-urllib3 python2-tornado python-unittest2
@ -70,6 +71,9 @@ LANG=en_US.UTF-8 %{__python3} -m nose2 -v
%{python3_sitelib}/httpretty-%{version}-py3.?.egg-info
%changelog
* Thu Oct 23 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 0.9.5-7
- Support old Python 2.7 releases (#341)
* Thu Nov 16 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 0.9.5-6
- fix query param matching