I'm wondering if it could be possible to support reusing some settings of a MockRouter instance, when invoking __call__. Basically that'll allow me to specify a MockRouter with defaults, and for specific test cases flip the assert_all_called-flag.
Consider the code below. I want base_url and assert_all_called to have its default, unless they're overriden by a new __call__ invocation
import httpx
import respx
default = respx.mock(base_url="http://some.where/", assert_all_called=False)
default.get(path="/here/")
with default(assert_all_called=True):
httpx.get("http://some.where/here/") # Raises: RESPX: <Request('GET', 'http://some.where/here/')> not mocked!
@default(assert_all_called=True)
def test_1():
httpx.get("http://some.where/here/") # Raises: RESPX: <Request('GET', 'http://some.where/here/')> not mocked!
test_1()
# This should still have the default `assert_all_called=False`
@default
def test_2():
httpx.get("http://some.where/here/") # This works
test_2()
Currently, this gives me an error whenever I pass in new kwargs to default(test_1 and with default). As __call__ is just creating a new MockRouter instance from scratch.
I'm realising as I write this that support for this might appear better through some additional MockRouter method (e.g. MockRouter.replace()) instead of changing __call__.
I'm wondering if it could be possible to support reusing some settings of a
MockRouterinstance, when invoking__call__. Basically that'll allow me to specify aMockRouterwith defaults, and for specific test cases flip theassert_all_called-flag.Consider the code below. I want
base_urlandassert_all_calledto have its default, unless they're overriden by a new__call__invocationCurrently, this gives me an error whenever I pass in new kwargs to
default(test_1andwith default). As__call__is just creating a newMockRouterinstance from scratch.I'm realising as I write this that support for this might appear better through some additional
MockRoutermethod (e.g.MockRouter.replace()) instead of changing__call__.