requests-mock/doc/source/adapter.rst
Jamie Lennox 9fbd45b35f Fix docs building
As part of review [1] the openstack build system assumes the layout of
the docs directories to be doc/build. This is not what requests-mock was
producing. Fix the docs building directories to make it work with the
build system again.

[1] Icb0c02dc5b6f7b5e248e0df6d6093c29535b08f3

Closes-Bug: #1630114
Change-Id: Iea93ecfb0506d5ccd0b79ad35f5677797fadf730
2016-10-04 16:34:16 +11:00

630 B

Adapter Usage

Creating an Adapter

The standard requests means of using an adapter is to :py~requests.Session.mount it on a created session. This is not the only way to load the adapter, however the same interactions will be used.

>>> import requests >>> import requests_mock

>>> session = requests.Session() >>> adapter = requests_mock.Adapter() >>> session.mount('mock', adapter)

At this point any requests made by the session to a URI starting with mock:// will be sent to our adapter.