Fix the error in the code that causes a ValueError exception to be thrown

Signed-off-by: zhang-liang-pengkun <zhangliangpengkun@xfusion.com>
This commit is contained in:
zhang-liang-pengkun 2023-12-29 16:20:44 +08:00
parent c3f51c910d
commit 89c8d1873a
2 changed files with 127 additions and 2 deletions

121
0004-lint.patch Normal file
View File

@ -0,0 +1,121 @@
From 2314893ec5ab46513e91ab867d7b55a72968909e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gabriel=20Falc=C3=A3o?= <gabriel@nacaolivre.org>
Date: Sun, 4 Nov 2018 23:32:50 +0100
Subject: [PATCH] lint
---
httpretty/http.py | 2 +-
tests/functional/test_httplib2.py | 2 +-
tests/functional/test_requests.py | 14 +++++++-------
tests/functional/test_urllib2.py | 2 +-
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/httpretty/http.py b/httpretty/http.py
index a256905..79dac73 100644
--- a/httpretty/http.py
+++ b/httpretty/http.py
@@ -133,7 +133,7 @@ def parse_requestline(s):
ValueError: Not a Request-Line
"""
methods = '|'.join(HttpBaseClass.METHODS)
- m = re.match(r'(' + methods + ')\s+(.*)\s+HTTP/(1.[0|1])', s, re.I)
+ m = re.match(r'(' + methods + r')\s+(.*)\s+HTTP/(1.[0|1])', s, re.I)
if m:
return m.group(1).upper(), m.group(2), m.group(3)
else:
diff --git a/tests/functional/test_httplib2.py b/tests/functional/test_httplib2.py
index 3b78043..9aa6a5b 100644
--- a/tests/functional/test_httplib2.py
+++ b/tests/functional/test_httplib2.py
@@ -295,7 +295,7 @@ def test_httpretty_should_allow_registering_regexes():
HTTPretty.register_uri(
HTTPretty.GET,
- re.compile("https://api.yipit.com/v1/deal;brand=(?P<brand_name>\w+)"),
+ re.compile(r"https://api.yipit.com/v1/deal;brand=(?P<brand_name>\w+)"),
body="Found brand",
)
diff --git a/tests/functional/test_requests.py b/tests/functional/test_requests.py
index e98b23f..06bdc1e 100644
--- a/tests/functional/test_requests.py
+++ b/tests/functional/test_requests.py
@@ -564,7 +564,7 @@ def test_httpretty_should_allow_registering_regexes_and_give_a_proper_match_to_t
HTTPretty.register_uri(
HTTPretty.GET,
- re.compile("https://api.yipit.com/v1/deal;brand=(?P<brand_name>\w+)"),
+ re.compile(r"https://api.yipit.com/v1/deal;brand=(?P<brand_name>\w+)"),
body=lambda method, uri, headers: [200, headers, uri]
)
@@ -581,7 +581,7 @@ def test_httpretty_should_allow_registering_regexes():
HTTPretty.register_uri(
HTTPretty.GET,
- re.compile("https://api.yipit.com/v1/deal;brand=(?P<brand_name>\w+)"),
+ re.compile(r"https://api.yipit.com/v1/deal;brand=(?P<brand_name>\w+)"),
body="Found brand",
)
@@ -598,7 +598,7 @@ def test_httpretty_provides_easy_access_to_querystrings_with_regexes():
HTTPretty.register_uri(
HTTPretty.GET,
- re.compile("https://api.yipit.com/v1/(?P<endpoint>\w+)/$"),
+ re.compile(r"https://api.yipit.com/v1/(?P<endpoint>\w+)/$"),
body="Find the best daily deals"
)
@@ -617,7 +617,7 @@ def test_httpretty_allows_to_chose_if_querystring_should_be_matched():
HTTPretty.register_uri(
HTTPretty.GET,
- re.compile("https://example.org/(?P<endpoint>\w+)/$"),
+ re.compile(r"https://example.org/(?P<endpoint>\w+)/$"),
body="Nudge, nudge, wink, wink. Know what I mean?",
match_querystring=True
)
@@ -659,7 +659,7 @@ def test_httpretty_should_allow_registering_regexes_with_streaming_responses():
HTTPretty.register_uri(
HTTPretty.POST,
- re.compile("https://api.yipit.com/v1/deal;brand=(?P<brand_name>\w+)"),
+ re.compile(r"https://api.yipit.com/v1/deal;brand=(?P<brand_name>\w+)"),
body=my_callback,
)
@@ -842,7 +842,7 @@ def test_httpretty_should_work_with_non_standard_ports():
HTTPretty.register_uri(
HTTPretty.GET,
- re.compile("https://api.yipit.com:1234/v1/deal;brand=(?P<brand_name>\w+)"),
+ re.compile(r"https://api.yipit.com:1234/v1/deal;brand=(?P<brand_name>\w+)"),
body=lambda method, uri, headers: [200, headers, uri]
)
HTTPretty.register_uri(
@@ -901,7 +901,7 @@ def test_httpretty_should_allow_registering_regexes_with_port_and_give_a_proper_
HTTPretty.register_uri(
HTTPretty.GET,
- re.compile("https://api.yipit.com:1234/v1/deal;brand=(?P<brand_name>\w+)"),
+ re.compile(r"https://api.yipit.com:1234/v1/deal;brand=(?P<brand_name>\w+)"),
body=lambda method, uri, headers: [200, headers, uri]
)
diff --git a/tests/functional/test_urllib2.py b/tests/functional/test_urllib2.py
index d1b92ee..c2a1732 100644
--- a/tests/functional/test_urllib2.py
+++ b/tests/functional/test_urllib2.py
@@ -326,7 +326,7 @@ def test_httpretty_should_allow_registering_regexes():
HTTPretty.register_uri(
HTTPretty.GET,
- re.compile("https://api.yipit.com/v1/deal;brand=(?P<brand_name>\w+)"),
+ re.compile(r"https://api.yipit.com/v1/deal;brand=(?P<brand_name>\w+)"),
body="Found brand",
)
--
2.39.0.windows.2

View File

@ -1,6 +1,6 @@
Name: python-httpretty
Version: 0.9.5
Release: 7
Release: 8
Summary: HTTP Client mocking tool for Python
License: MIT
URL: https://pypi.org/project/httpretty/
@ -12,6 +12,7 @@ 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
Patch0007: 0004-lint.patch
BuildRequires: python2-devel python2-setuptools python2-httplib2 python2-mock python2-nose
BuildRequires: python2-requests python2-sure python2-urllib3 python2-tornado python-unittest2
@ -71,10 +72,13 @@ LANG=en_US.UTF-8 %{__python3} -m nose2 -v
%{python3_sitelib}/httpretty-%{version}-py3.?.egg-info
%changelog
* Thu Dec 28 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 0.9.5-8
- lint
* 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
* Fri Nov 10 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 0.9.5-6
- fix query param matching
* Fri Dec 30 2022 yaoxin <yaoxin30@h-partners.com> - 0.9.5-5