-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
fix: assertion of DynamoType failing #7073
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's odd - and must have been fun to debug!
This is definitely something that would need a test case though, just to prevent us from ever re-introducing the bug by accident.
Just out of interest - can it be reproduced by using the manual mocks?
m = mock_dynamodb().
m.start().
..
m.stop()
# reloading magic
m.start()
m.stop()
If so, that would mean the fix could be verified in a single test.
681e1d5
to
d6b0e16
Compare
@bblommers "fun to debug!" is certainly one way to put it 😅 I have added a self-contained test which reproduces the issue using the style you've suggested. |
tests/test_dynamodb/test_dynamodb.py
Outdated
|
||
mock_dynamo = mock_dynamodb() | ||
mock_dynamo.start() | ||
dynamo_client = boto3.client("dynamodb") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our CI does not have a region configured, so we have to specify it here explicitly
ExpressionAttributeValues={ | ||
":some_value": {"M": {"Some key": {"S": "Some new value"}}} | ||
}, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should stop the mock at the end:
mock_dynamo.stop()
Not a big problem if you only run the one test, but if you run multiple tests and one mock is still active, it wreaks havoc.
Hmm.. Our CI still doesn't seem to like that. All the tests after the new tests are now failing:
|
This is a complete test which reproduces the issue.
The
reload
function is sourced from this Stack Overflow response. Our tests currently rely on this behaviour. The use of this function contributes to the occurrence of this bug.Running the above code results in this assertion failing:
moto/moto/dynamodb/parsing/ast_nodes.py
Line 330 in bfac8a8
It seems something along the lines of this is going on: the
reload
function combined with the inconsistent imports means two different instances ofDynamoType
coexist and are in use.Because the
reload
function is called between test invocations, this error only occurs when more than one test runs in a single pytest execution. So with the example above, running each case individually they'll both pass.If appropriate, I can add the example above as a test here.