Skip to content
Myr

Merge pull request #4987 from aless10/master

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

[fix] fix failing doctests in requests/*

authored by Kenneth Reitz · committed by GitHub · parents ada5049, df918c0 · Browse files · 8 files+18 added−9 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+18 added−9 removed

  • other:+18 added−9 removed

8 files+18 added−9 removed

modified:requests/__init__.py+5 added-5 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:23
2 unmodified lines
26 >>> print(r.text)27 {28 ...29 "form": {30 "key2": "value2",31 "key1": "value1"30 "key1": "value1",31 "key2": "value2"32 },33 ...34 }35
96 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
104 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)
684 unmodified lines
modified:requests/sessions.py+1 added-1 removed
352 unmodified lines
353354 Or as a context manager::355356 >>> with requests.Session() as s:357 >>> s.get('https://httpbin.org/get')357 ... s.get('https://httpbin.org/get')358 <Response [200]>359 """360361 __attrs__ = [
413 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
265 unmodified lines
266267 >>> from_key_val_list([('key', 'val')])268 OrderedDict([('key', 'val')])269 >>> from_key_val_list('string')270 Traceback (most recent call last):271 ...272 ValueError: cannot encode objects that are not 2-tuples273 >>> from_key_val_list({'key': 'val'})274 OrderedDict([('key', 'val')])275
18 unmodified lines
294 [('key', 'val')]295 >>> to_key_val_list({'key': 'val'})296 [('key', 'val')]297 >>> to_key_val_list('string')298 Traceback (most recent call last):299 ...296 ValueError: cannot encode objects that are not 2-tuples.300 ValueError: cannot encode objects that are not 2-tuples301302 :rtype: list303 """304 if value is None:
678 unmodified lines
modified:AUTHORS.rst+2 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- "Dull Bananas" <dull.bananas0@gmail.com> (`@dullbananas <https://github.com/dullbananas>`_)193- Alessio Izzo (`@aless10 <https://github.com/aless10>`_)194- Belavin Denis (`@luckydenis <https://github.com/luckydenis>`_)195- Dull Bananas <dull.bananas0@gmail.com> (`@dullbananas <https://github.com/dullbananas>`_)
modified:pytest.ini+2 added-1 removed
1[pytest]2addopts = -p no:warnings2addopts = -p no:warnings --doctest-modules3doctest_optionflags= NORMALIZE_WHITESPACE ELLIPSIS