[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
Provenance
- Commit
177f4dd- Tree
727c16f- Author
aless10 <alessio.izzo86@gmail.com>- Committer
aless10 <alessio.izzo86@gmail.com>- Parent
c9309e4
8 files changed+17 added−17 removed
modified:requests/__init__.py+6 added-13 removed
7 unmodified lines8 """9 Requests HTTP Library10 ~~~~~~~~~~~~~~~~~~~~~11 12-Requests is an HTTP library, written in Python, for human beings. Basic GET13-usage:12+Requests is an HTTP library, written in Python, for human beings.13+Basic GET usage:14 15 >>> 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 True21 22-... or POST:22+Basic POST usage:23 24 >>> 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'}28 29 The other HTTP methods are supported - see `requests.api`. Full documentation30 is at <http://python-requests.org>.31 93 unmodified linesmodified:requests/api.py+1 added
48 unmodified lines49 Usage::50 51 >>> import requests52 >>> req = requests.request('GET', 'https://httpbin.org/get')53+ >>> req54 <Response [200]>55 """56 57 # By using the 'with' statement we are sure the session is closed, thus we102 unmodified linesmodified:requests/models.py+1 added
278 unmodified lines279 280 >>> import requests281 >>> req = requests.Request('GET', 'https://httpbin.org/get')282 >>> r = req.prepare()283+ >>> r284 <PreparedRequest [GET]>285 286 >>> s = requests.Session()287 >>> s.send(r)667 unmodified linesmodified:requests/sessions.py+1 added-1 removed
350 unmodified lines351 352 Or as a context manager::353 354 >>> with requests.Session() as s:355- >>> s.get('https://httpbin.org/get')355+ ... s.get('https://httpbin.org/get')356 <Response [200]>357 """358 359 __attrs__ = [411 unmodified linesmodified:requests/status_codes.py+1 added-1 removed
2 unmodified lines3 r"""4 The ``codes`` object defines a mapping from common names for HTTP statuses5 to their numerical codes, accessible either as attributes or as dictionary6 items.7-7+>>> import requests8 >>> requests.codes['temporary_redirect']9 30710 >>> requests.codes.teapot11 418109 unmodified linesmodified:requests/utils.py+5 added-1 removed
264 unmodified lines265 266 >>> 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 lines293 [('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-tuples300 301 :rtype: list302 """303 if value is None:678 unmodified linesmodified:AUTHORS.rst+1 added
187 unmodified lines188 - 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]2-addopts = -p no:warnings2+addopts = -p no:warnings --doctest-modules