When matching URLs both strings are always lowercased to provide case
insensitive matching. Whilst this makes sense for the protocol and the
host names it does not necessarily hold true for paths and query
strings.
A byproduct of this is that the lowercased strings are being reported in
request_history which makes it harder to verify requests you made.
We enable globally and per adapter setting case sensitive matching. This
is intended to become the default in future releases.
Change-Id: I7bde70a52995ecf31a0eaeff96f2823a1a6682b2
Closes-Bug: #1584008
Allow installing the additional requirements for using the fixture
contrib module using pip extras.
Closes-Bug: #1501665
Change-Id: I20510d8db35c3cfdc0bc2892675b04d224027c7e
If you set up requests_mock to catch all requests (which I would
recommend) you sometimes get caught with things like file:// paths that
should be allowed to reach the filesystem.
To do this we should allow you to add a matcher that says a specific
route can bypass the catch all and do a real request.
This is a bit of a layer violation but I thought it was easy to start
with, then realized why it wasn't.
Change-Id: Ic2516f78413b88a489c8d6bd2bc39b8ebb5bf273
Closes-Bug: #1501665
Cookies are treated unusually in requests. To handle them exactly as
requests does we would need to create httplib responses with headers and
pass those back. This would be a significant change that is a little
tricky. Instead use the available requests cookies handlers to merge the
cookies into the responses returned from the adapter.
Provide a way to create and preload a CookieJar that will be returned as
part of responses. We also provide the dict interface that requests
does. We don't really have a lot of choice here as these interfaces are
supported by the cookie apis and we would need to actively work around
things to remove that interface.
Change-Id: Ifc1253abc1b4004e81aa7bffad1faf32aedd0d4c
Closes-Bug: #1480835
Now it is possible to mock not only a function but also a class:
class TestClass(object)
def test_func_a(self, m):
m.register_uri('GET', 'http://test.com', text='data')
...
def test_func_b(self, m)
m.register_uri('GET', 'http://test.com', text='data')
...
This new behavior mimics behavior of `patch` from `mock` library.
Added docs for this new feature.
Closes-Bug: #1404805
Change-Id: I8303dc4bc682cf12ffe86e7712b5a1c54de83efb
Firstly privatize everything on the existing matcher object as it is now
going to be a public interface.
Add called and call_count parameters for querying how many times that
particular mock was invoked. We do this by saving a reference to every
request that passes through. This is inefficient for now, however it
lets us do more interesting things like called_with in the future.