`test_protocols.test_output_compliance`: `case` should be copied
Describe the bug
The test_output_compliance test does copy.deepcopy on json_description, but not on case. This is despite both being shared among test function invocations and both being modified. This means that if the test gets parametrized, or is rerun due to pytest-rerunfailures, or similar, the test fails.
https://github.com/boto/botocore/blob/a4bd6ae3b0c76ea2e515b4851e970fea5768ceb2/tests/unit/test_protocols.py#L197-L206
Regression Issue
- [ ] Select this option if this issue appears to be a regression.
Possible Solution
Add
case = copy.deepcopy(case)
Additional Information/Context
This was noticed in https://github.com/aio-libs/aiobotocore/pull/1085/
Hello @jakkdl, thanks for reaching out. I have tested the code and confirmed it does re-use the same case object between test runs, causing failures when tests are parametrized or rerun. I will bring this up to the team if case = copy.deepcopy(case) can be added. Thank you.
Hi @jakkdl, thanks for the patience. Could you please provide your use case and also how you are implementing or reproducing this? Also, please add boto3.set_stream_logger('') for logs too. Thanks.
Hi @jakkdl, thanks for the patience. Could you please provide your use case and also how you are implementing or reproducing this? Also, please add boto3.set_stream_logger('') for logs too. Thanks.
https://github.com/aio-libs/aiobotocore/ runs a copy of the test suite from botocore with minimal changes, maintaining a diff to make sure they match the behavior of upstream. But https://github.com/aio-libs/aiobotocore/pull/1085 wanted to introduce parametrization of the test suite, which made this test fail. https://github.com/jakkdl/aiobotocore/blob/25351b7064451a15df957fea66486d94a841b69e/tests/conftest.py#L703-L718
It's not really a problem currently for botocore, but I could see it biting somebody in the future. Either if somebody adds parametrization, adds another test that makes use of _compliance_tests, uses pytest-rerunfailures and it fails for a diff reason the first time, etc. And it saves aiobotocore having to maintain a diff relative to upstream :)
I don't think logs are terribly useful here, and idk where to add boto3.set_stream_logger to do anything useful - the relevant test file isn't importing boto3 in the first case.
Thanks for getting back. The test suite helps us validate botocore functionality, and since botocore is working as expected, we won't need to make any adjustments at this time.
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.