From 762b662a5f8770215390b075234b90f95f6ee41c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Arkadiusz=20Mi=C5=9Bkiewicz?= Date: Thu, 4 Dec 2014 12:08:50 +0100 Subject: [PATCH] - offline tests --- python-requests.spec | 2 ++ requests-test.patch | 70 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 requests-test.patch diff --git a/python-requests.spec b/python-requests.spec index 5402b0b..1ffd4dc 100644 --- a/python-requests.spec +++ b/python-requests.spec @@ -22,6 +22,7 @@ URL: http://python-requests.org # + manual removal from setup.py Patch0: system-charade-and-urllib3.patch Patch1: system-cert.patch +Patch2: requests-test.patch %if %{with python2} BuildRequires: python-modules >= 1:2.6 %if %{without bundled} @@ -114,6 +115,7 @@ Ten pakiet zawiera moduł dla Pythona 3.x. %setup -q -n %{module}-%{version} %{!?with_bundled:%patch0 -p1} %patch1 -p1 +%patch2 -p1 %build %if %{with python2} diff --git a/requests-test.patch b/requests-test.patch new file mode 100644 index 0000000..76a91d8 --- /dev/null +++ b/requests-test.patch @@ -0,0 +1,70 @@ +From cf82d4406be55c71983d05d7f6e18917540b5c69 Mon Sep 17 00:00:00 2001 +From: Ian Cordasco +Date: Mon, 1 Dec 2014 16:21:41 -0600 +Subject: [PATCH] Update tests to work offline + +--- + test_requests.py | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/test_requests.py b/test_requests.py +index 4624f09..2d3ee62 100755 +--- a/test_requests.py ++++ b/test_requests.py +@@ -258,7 +258,7 @@ def test_headers_on_session_with_None_are_not_sent(self): + """Do not send headers in Session.headers with None values.""" + ses = requests.Session() + ses.headers['Accept-Encoding'] = None +- req = requests.Request('GET', 'http://httpbin.org/get') ++ req = requests.Request('GET', httpbin('get')) + prep = ses.prepare_request(req) + assert 'Accept-Encoding' not in prep.headers + +@@ -1008,12 +1008,12 @@ def test_basic_auth_str_is_always_native(self): + assert s == "Basic dGVzdDp0ZXN0" + + def test_requests_history_is_saved(self): +- r = requests.get('https://httpbin.org/redirect/5') ++ r = requests.get(httpbin('redirect/5')) + total = r.history[-1].history + i = 0 + for item in r.history: + assert item.history == total[0:i] +- i=i+1 ++ i = i + 1 + + def test_json_param_post_content_type_works(self): + r = requests.post( +@@ -1350,7 +1350,7 @@ def test_max_age_invalid_str(self): + class TestTimeout: + def test_stream_timeout(self): + try: +- requests.get('https://httpbin.org/delay/10', timeout=2.0) ++ requests.get(httpbin('delay/10'), timeout=2.0) + except requests.exceptions.Timeout as e: + assert 'Read timed out' in e.args[0].args[0] + +@@ -1450,7 +1450,7 @@ class TestRedirects: + + def test_requests_are_updated_each_time(self): + session = RedirectSession([303, 307]) +- prep = requests.Request('POST', 'http://httpbin.org/post').prepare() ++ prep = requests.Request('POST', httpbin('post')).prepare() + r0 = session.send(prep) + assert r0.request.method == 'POST' + assert session.calls[-1] == SendCall((r0.request,), {}) +@@ -1534,12 +1534,12 @@ def test_prepare_unicode_url(): + def test_urllib3_retries(): + from requests.packages.urllib3.util import Retry + s = requests.Session() +- s.mount('https://', HTTPAdapter(max_retries=Retry( ++ s.mount('http://', HTTPAdapter(max_retries=Retry( + total=2, status_forcelist=[500] + ))) + + with pytest.raises(RetryError): +- s.get('https://httpbin.org/status/500') ++ s.get(httpbin('status/500')) + + if __name__ == '__main__': + unittest.main() -- 2.44.0