Skip to content

Commit

Permalink
Merge pull request #4987 from aless10/master
Browse files Browse the repository at this point in the history
[fix] fix failing doctests in requests/*
  • Loading branch information
kennethreitz authored Aug 20, 2019
2 parents ada5049 + df918c0 commit 3e7d0a8
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 9 deletions.
2 changes: 2 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,7 @@ Patches and Suggestions
- Darren Dormer (`@ddormer <https://github.com/ddormer>`_)
- Rajiv Mayani (`@mayani <https://github.com/mayani>`_)
- Antti Kaihola (`@akaihola <https://github.com/akaihola>`_)
- "Dull Bananas" <[email protected]> (`@dullbananas <https://github.com/dullbananas>`_)
- Alessio Izzo (`@aless10 <https://github.com/aless10>`_)
- Belavin Denis (`@luckydenis <https://github.com/luckydenis>`_)
- Dull Bananas <[email protected]> (`@dullbananas <https://github.com/dullbananas>`_)
3 changes: 2 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[pytest]
addopts = -p no:warnings
addopts = -p no:warnings --doctest-modules
doctest_optionflags= NORMALIZE_WHITESPACE ELLIPSIS
10 changes: 5 additions & 5 deletions requests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
Requests HTTP Library
~~~~~~~~~~~~~~~~~~~~~
Requests is an HTTP library, written in Python, for human beings. Basic GET
usage:
Requests is an HTTP library, written in Python, for human beings.
Basic GET usage:
>>> import requests
>>> r = requests.get('https://www.python.org')
>>> r.status_code
200
>>> 'Python is a programming language' in r.content
>>> b'Python is a programming language' in r.content
True
... or POST:
Expand All @@ -27,8 +27,8 @@
{
...
"form": {
"key2": "value2",
"key1": "value1"
"key1": "value1",
"key2": "value2"
},
...
}
Expand Down
1 change: 1 addition & 0 deletions requests/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def request(method, url, **kwargs):
>>> import requests
>>> req = requests.request('GET', 'https://httpbin.org/get')
>>> req
<Response [200]>
"""

Expand Down
1 change: 1 addition & 0 deletions requests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
>>> import requests
>>> req = requests.Request('GET', 'https://httpbin.org/get')
>>> r = req.prepare()
>>> r
<PreparedRequest [GET]>
>>> s = requests.Session()
Expand Down
2 changes: 1 addition & 1 deletion requests/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ class Session(SessionRedirectMixin):
Or as a context manager::
>>> with requests.Session() as s:
>>> s.get('https://httpbin.org/get')
... s.get('https://httpbin.org/get')
<Response [200]>
"""

Expand Down
2 changes: 1 addition & 1 deletion requests/status_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
The ``codes`` object defines a mapping from common names for HTTP statuses
to their numerical codes, accessible either as attributes or as dictionary
items.
>>> import requests
>>> requests.codes['temporary_redirect']
307
>>> requests.codes.teapot
Expand Down
6 changes: 5 additions & 1 deletion requests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ def from_key_val_list(value):
>>> from_key_val_list([('key', 'val')])
OrderedDict([('key', 'val')])
>>> from_key_val_list('string')
Traceback (most recent call last):
...
ValueError: cannot encode objects that are not 2-tuples
>>> from_key_val_list({'key': 'val'})
OrderedDict([('key', 'val')])
Expand All @@ -293,7 +295,9 @@ def to_key_val_list(value):
>>> to_key_val_list({'key': 'val'})
[('key', 'val')]
>>> to_key_val_list('string')
ValueError: cannot encode objects that are not 2-tuples.
Traceback (most recent call last):
...
ValueError: cannot encode objects that are not 2-tuples
:rtype: list
"""
Expand Down

0 comments on commit 3e7d0a8

Please sign in to comment.