Update README to use newer syntax
Update the example code on the README to use the .get() function rather than register_uri('GET'). This is the first thing most people see and we want to make that look as clean as possible. Change-Id: I87e0d40d76f70acfbe8ba9686a5ea5a6b0d73f85
This commit is contained in:
parent
ca1c6dd58a
commit
57f9c6a8f5
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