-
-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
upgrade from 2.2.X to 2.3.X breaks tests using botocore.stub.Stubber #939
Comments
I also run in the same issue, version 2.3.0 (required by aioboto3 9.6.0) on python 3.10.4. Unit tests that worked fine in 2.3.0 and older no longer work. |
will look asap, sorry for delay |
@thehesiod any updates? |
@thehesiod I see updates being made, but this is still a problem. |
@thehesiod @jakob-keller is there a chance the Stubber is ever going to be fixed? Something broke in version 2.3.0 and in other to keep my unit tests I have to keep |
This is the PR that introduced the problem: #934 |
sorry haven't had a chance to look into this yet |
@thehesiod any idea what could be broken? I could try to fix it, but I don't even know where to start. I isolated the PR via bisect. |
i tried that test above in the latest aiobotocore and it passes after adding |
The Stubber is builtin component of botocore that is meant for unit testing: https://botocore.amazonaws.com/v1/documentation/api/latest/reference/stubber.html After 2.3.0 change the Stubber() object is a NO-OP, the API still tries to talk to AWS. |
ok will re-try, it's because right now our test infra doesn't run tests that don't have moto enabled, I'll try it w/o |
any luck? |
So I started migrating to moto, which apparently is broken and currently also need workaround and also doesn't let me test everything. So since either doesn't work correctly I started working with simple example so I used one in this bug. Interestingly this unit tests passes in latest version. I tried to do bisect but git complained that working version and broken don't share common ancestor (is the code rebased on every major version?) Anyway, I traced it manually to this PR: #989 it baffles me how this change somehow fixed the issue for this access. I still do have problem though, with ec2, ssm and elbv2 so I will try to come up with another unit test that fails. |
So after more investigation the issue was also introduced by #934 as well. Basically I created a fixture to use Stubber, like this: @pytest_asyncio.fixture()
async def fake_ssm():
async with aioboto3.Session().client("ssm") as client:
fake_session = create_autospec(aioboto3.Session, spec_set=True)
fake_session.client = MagicMock(return_value=client)
ssm_obj = ssm.SSM(b3_session=fake_session)
stubber = Stubber(client)
with stubber:
yield FakeSSM(ssm_obj, stubber)
stubber.assert_no_pending_responses() this now produces assertion error:
This worked in 2.2.3 @pytest_asyncio.fixture()
async def fake_ssm():
async with aioboto3.Session().client("ssm") as client:
fake_session = create_autospec(aioboto3.Session, spec_set=True)
fake_session.client = MagicMock(return_value=client)
ssm_obj = ssm.SSM(b3_session=fake_session)
stubber = Stubber(client)
with stubber:
yield FakeSSM(ssm_obj, stubber)
stubber.assert_no_pending_responses() and it seems to be working again. As far as I'm concerned this issue is resolved. @akursar, is it also working for you? |
so I tested the original testcase w/o moto and it passes fine with latest version, shall we close? |
I think so. I needed to adapt my code a bit, but looking at the assertion I think I was maybe using it incorrectly and the old version was just allowing it. |
btw using the sync stubber is not really correct, as it doesn't return the AioAWSResponse...technically we should have an AioStubber...however unless you need the functionality no biggie |
I don't know internals of botocore, but I got impression that stubber just adds hooks to the client and provides responses set up with It seems to work so far, but if there might be some issues, I'm interested what would need to be changed? |
stuff like https://github.com/boto/botocore/blob/develop/botocore/stub.py#L247 should return aiobotocore/aiobotocore/awsrequest.py Line 5 in 88a4309
|
@thehesiod I myself don't use the headers so far, but created PR, is that what were you thinking: #1039 |
Describe the bug
Upgrading from 2.2.X to 2.3.X causes tests that use Stubber to fail. I have this example test, which is an aiobotocore version of the example described at https://botocore.amazonaws.com/v1/documentation/api/latest/reference/stubber.html#botocore.stub.Stubber
The test passes if I downgrade to 2.2.0, but fails with 2.3.0 (and 2.3.2).
I'm not sure if aiobotocore seeks to be compatible with Stubber, but it seemed worthwhile to report the issue.
It passes for 2.2.0 but fails for 2.3.0 with
Checklist
pip check
passes without errorspip freeze
resultssort of. i am not changing the version of aiohttp but am only updating aiobotocore
pip freeze results
Environment:
The text was updated successfully, but these errors were encountered: