Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Conversation

@sturmianseq
Copy link

What is the purpose of the change

This PR is to fix a flaky test tests/test_api_client.py::TestApiClient::test_authentication_error, which can fail after running tests/test_api_client.py::TestApiClient::test_param_required_error, but passes when it is run in isolation.

Reproduce the test failure

Run the following command:

python -m pytest tests/test_api_client.py::TestApiClient::test_param_required_error tests/test_api_client.py::TestApiClient::test_authentication_error

Expected result

Test tests/test_api_client.py::TestApiClient::test_authentication_error should pass when it is run after test tests/test_api_client.py::TestApiClient::test_param_required_error.

Actual result

Test tests/test_api_client.py::TestApiClient::test_authentication_error fails:

   def _proceed_response(self, response):
        if not response.ok:
>           raise build_api_error(response)
E           coinbase_commerce.error.ParamRequiredError: Request id <MagicMock name='mock.get().headers.get()' id='140023001166560'>: <empty message>

coinbase_commerce/client.py:89: ParamRequiredError

Why the test fails

The error return value of mock.MagicMock.content is polluted after tests/test_api_client.py::TestApiClient::test_param_required_error.

Fix

Reset mock.MagicMock.content at the start of tests/test_api_client.py::TestApiClient::test_authentication_error.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant