Skip to content

Instantly share code, notes, and snippets.

@afonasev
Last active January 27, 2020 11:03
Show Gist options
  • Save afonasev/e523ef157efe7a5057e898ba19fcf871 to your computer and use it in GitHub Desktop.
Save afonasev/e523ef157efe7a5057e898ba19fcf871 to your computer and use it in GitHub Desktop.
Utils for responses lib
@pytest.fixture(autouse=True)
def mock_request():
with responses.RequestsMock() as req:
yield req
@pytest.fixture()
def check_request(mock_request):
def _check_request(body):
if isinstance(body, dict):
body = json.dumps(body)
assert mock_request.calls[0].request.body.decode() == body
return _check_request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment