Skip to content
Myr

[fix] fix failing doctests in requests/*

Before adoption: this commit came in with the history the project adopted, so no landing records it.

[add] add --doctest-modules in pytest.ini file as addopts [add] add myself to AUTHORS

authored by aless10 · committed by aless10 · parent c9309e4 · Browse files · 8 files+17 added−17 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

8 files+17 added−17 removed

  • other:+17 added−17 removed

8 files+17 added−17 removed

modified:requests/__init__.py+6 added-13 removed
7 unmodified lines
8"""9Requests HTTP Library10~~~~~~~~~~~~~~~~~~~~~1112Requests is an HTTP library, written in Python, for human beings. Basic GET13usage:12Requests is an HTTP library, written in Python, for human beings.13Basic GET usage:1415 >>> import requests16 >>> r = requests.get('https://www.python.org')17 >>> r.status_code18 20019 >>> 'Python is a programming language' in r.content19 >>> b'Python is a programming language' in r.content20 True2122... or POST:22Basic POST usage:2324 >>> payload = dict(key1='value1', key2='value2')25 >>> r = requests.post('https://httpbin.org/post', data=payload)26 >>> print(r.text)27 {28 ...29 "form": {30 "key2": "value2",31 "key1": "value1"32 },33 ...34 }26 >>> r.json()27 {'args': {}, 'data': '', 'files': {}, 'form': {'key1': 'value1', 'key2': 'value2'}, 'headers': {'Accept': '*/*', 'Accept-Encoding': 'gzip, deflate', 'Connection': 'close', 'Content-Length': '23', 'Content-Type': 'application/x-www-form-urlencoded', 'Host': 'httpbin.org', 'User-Agent': 'python-requests/...'}, 'json': None, 'origin': '...', 'url': 'https://httpbin.org/post'}2829The other HTTP methods are supported - see `requests.api`. Full documentation30is at <http://python-requests.org>.31
93 unmodified lines
modified:requests/api.py+1 added
48 unmodified lines
49 Usage::5051 >>> import requests52 >>> req = requests.request('GET', 'https://httpbin.org/get')53 >>> req54 <Response [200]>55 """5657 # By using the 'with' statement we are sure the session is closed, thus we
102 unmodified lines
modified:requests/models.py+1 added
278 unmodified lines
279280 >>> import requests281 >>> req = requests.Request('GET', 'https://httpbin.org/get')282 >>> r = req.prepare()283 >>> r284 <PreparedRequest [GET]>285286 >>> s = requests.Session()287 >>> s.send(r)
667 unmodified lines
modified:requests/sessions.py+1 added-1 removed
350 unmodified lines
351352 Or as a context manager::353354 >>> with requests.Session() as s:355 >>> s.get('https://httpbin.org/get')355 ... s.get('https://httpbin.org/get')356 <Response [200]>357 """358359 __attrs__ = [
411 unmodified lines
modified:requests/status_codes.py+1 added-1 removed
2 unmodified lines
3r"""4The ``codes`` object defines a mapping from common names for HTTP statuses5to their numerical codes, accessible either as attributes or as dictionary6items.77>>> import requests8>>> requests.codes['temporary_redirect']930710>>> requests.codes.teapot11418
109 unmodified lines
modified:requests/utils.py+5 added-1 removed
264 unmodified lines
265266 >>> from_key_val_list([('key', 'val')])267 OrderedDict([('key', 'val')])268 >>> from_key_val_list('string')269 Traceback (most recent call last):270 ...271 ValueError: cannot encode objects that are not 2-tuples272 >>> from_key_val_list({'key': 'val'})273 OrderedDict([('key', 'val')])274
18 unmodified lines
293 [('key', 'val')]294 >>> to_key_val_list({'key': 'val'})295 [('key', 'val')]296 >>> to_key_val_list('string')297 Traceback (most recent call last):298 ...295 ValueError: cannot encode objects that are not 2-tuples.299 ValueError: cannot encode objects that are not 2-tuples300301 :rtype: list302 """303 if value is None:
678 unmodified lines
modified:AUTHORS.rst+1 added
187 unmodified lines
188- Demetrios Bairaktaris (`@DemetriosBairaktaris <https://github.com/demetriosbairaktaris>`_)189- Darren Dormer (`@ddormer <https://github.com/ddormer>`_)190- Rajiv Mayani (`@mayani <https://github.com/mayani>`_)191- Antti Kaihola (`@akaihola <https://github.com/akaihola>`_)192- Alessio Izzo (`@aless10 <https://github.com/aless10>`_)
modified:pytest.ini+1 added-1 removed
1[pytest]2addopts = -p no:warnings2addopts = -p no:warnings --doctest-modules