diff --git a/AUTHORS.rst b/AUTHORS.rst index 3e8f36c2..607f65e1 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -189,5 +189,7 @@ Patches and Suggestions - Darren Dormer (`@ddormer `_) - Rajiv Mayani (`@mayani `_) - Antti Kaihola (`@akaihola `_) +- "Dull Bananas" (`@dullbananas `_) +- Alessio Izzo (`@aless10 `_) - Belavin Denis (`@luckydenis `_) - Dull Bananas (`@dullbananas `_) diff --git a/pytest.ini b/pytest.ini index c1fa8785..13fa0000 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,3 @@ [pytest] -addopts = -p no:warnings \ No newline at end of file +addopts = -p no:warnings --doctest-modules +doctest_optionflags= NORMALIZE_WHITESPACE ELLIPSIS \ No newline at end of file diff --git a/requests/__init__.py b/requests/__init__.py index 9a899df6..3486f5e1 100644 --- a/requests/__init__.py +++ b/requests/__init__.py @@ -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: @@ -27,8 +27,8 @@ usage: { ... "form": { - "key2": "value2", - "key1": "value1" + "key1": "value1", + "key2": "value2" }, ... } diff --git a/requests/api.py b/requests/api.py index 88cfdceb..e978e203 100644 --- a/requests/api.py +++ b/requests/api.py @@ -50,6 +50,7 @@ def request(method, url, **kwargs): >>> import requests >>> req = requests.request('GET', 'https://httpbin.org/get') + >>> req """ diff --git a/requests/models.py b/requests/models.py index a0592439..ea332e7e 100644 --- a/requests/models.py +++ b/requests/models.py @@ -280,6 +280,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): >>> import requests >>> req = requests.Request('GET', 'https://httpbin.org/get') >>> r = req.prepare() + >>> r >>> s = requests.Session() diff --git a/requests/sessions.py b/requests/sessions.py index d97494d9..6d51820c 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -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') """ diff --git a/requests/status_codes.py b/requests/status_codes.py index 813e8c4e..4e99ad73 100644 --- a/requests/status_codes.py +++ b/requests/status_codes.py @@ -4,7 +4,7 @@ r""" 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 diff --git a/requests/utils.py b/requests/utils.py index 5636480d..c1700d7f 100644 --- a/requests/utils.py +++ b/requests/utils.py @@ -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')]) @@ -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 """