From 89c8d1873a4ce33d5ba61f8fd848f10f50333fc7 Mon Sep 17 00:00:00 2001 From: zhang-liang-pengkun Date: Fri, 29 Dec 2023 16:20:44 +0800 Subject: [PATCH] Fix the error in the code that causes a ValueError exception to be thrown Signed-off-by: zhang-liang-pengkun --- 0004-lint.patch | 121 ++++++++++++++++++++++++++++++++++++++++++ python-httpretty.spec | 8 ++- 2 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 0004-lint.patch diff --git a/0004-lint.patch b/0004-lint.patch new file mode 100644 index 0000000..3329c02 --- /dev/null +++ b/0004-lint.patch @@ -0,0 +1,121 @@ +From 2314893ec5ab46513e91ab867d7b55a72968909e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Gabriel=20Falc=C3=A3o?= +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\w+)"), ++ re.compile(r"https://api.yipit.com/v1/deal;brand=(?P\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\w+)"), ++ re.compile(r"https://api.yipit.com/v1/deal;brand=(?P\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\w+)"), ++ re.compile(r"https://api.yipit.com/v1/deal;brand=(?P\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\w+)/$"), ++ re.compile(r"https://api.yipit.com/v1/(?P\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\w+)/$"), ++ re.compile(r"https://example.org/(?P\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\w+)"), ++ re.compile(r"https://api.yipit.com/v1/deal;brand=(?P\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\w+)"), ++ re.compile(r"https://api.yipit.com:1234/v1/deal;brand=(?P\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\w+)"), ++ re.compile(r"https://api.yipit.com:1234/v1/deal;brand=(?P\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\w+)"), ++ re.compile(r"https://api.yipit.com/v1/deal;brand=(?P\w+)"), + body="Found brand", + ) + +-- +2.39.0.windows.2 + diff --git a/python-httpretty.spec b/python-httpretty.spec index 11249c2..aba02e5 100644 --- a/python-httpretty.spec +++ b/python-httpretty.spec @@ -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 - 0.9.5-8 +- lint + * Thu Oct 23 2023 zhangliangpengkun - 0.9.5-7 - Support old Python 2.7 releases (#341) -* Thu Nov 16 2023 zhangliangpengkun - 0.9.5-6 +* Fri Nov 10 2023 zhangliangpengkun - 0.9.5-6 - fix query param matching * Fri Dec 30 2022 yaoxin - 0.9.5-5 -- Gitee