Last active
January 27, 2020 11:03
-
-
Save afonasev/e523ef157efe7a5057e898ba19fcf871 to your computer and use it in GitHub Desktop.
Utils for responses lib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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