Merge "Update README to use newer syntax"
This commit is contained in:
commit
2412155489
10
README.rst
10
README.rst
@ -38,14 +38,14 @@ A simple example:
|
||||
>>> resp.status_code, resp.text
|
||||
(200, 'data')
|
||||
|
||||
Obviously having all URLs be `mock://` prefixed isn't going to useful, so you use the `requests_mock.Mocker` to get the adapter into place.
|
||||
Obviously having all URLs be `mock://` prefixed isn't going to useful, so you can use `requests_mock.mock` to get the adapter into place.
|
||||
|
||||
As a context manager:
|
||||
|
||||
.. code:: python
|
||||
|
||||
>>> with requests_mock.Mocker() as m:
|
||||
... m.register_uri('GET', 'http://test.com', text='data')
|
||||
>>> with requests_mock.mock() as m:
|
||||
... m.get('http://test.com', text='data')
|
||||
... requests.get('http://test.com').text
|
||||
...
|
||||
'data'
|
||||
@ -54,9 +54,9 @@ Or as a decorator:
|
||||
|
||||
.. code:: python
|
||||
|
||||
>>> @requests_mock.Mocker()
|
||||
>>> @requests_mock.mock()
|
||||
... def test_func(m):
|
||||
... m.register_uri('GET', 'http://test.com', text='data')
|
||||
... m.get('http://test.com', text='data')
|
||||
... return requests.get('http://test.com').text
|
||||
...
|
||||
>>> test_func()
|
||||
|
Loading…
x
Reference in New Issue
Block a user