-
-
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
s3 bucket state isn't persisting as I expect #4967
Comments
Hi @BenjaminCaffrey, welcome to Moto! It does work like this, by extending the BaseClass with the unittest.TestCase-class:
Note that executing the
|
Having said that, looking at your example, running |
Thank you @bblommers ! Let me know if there's anything I can do to help. To clarify my understanding of the situation: In your snippet, if we were to run But when we do the same thing with moto and mocked boto3 state (the snippet I posted), it doesn't seem to be the case. |
Yes, that is correct. The class-decorator is responsible for resetting the state between tests. On basic classes, it will reset before every test-method. If the class extends The underlying issue is that the class-decorator acts on compile-time. The only context we have at that point, is that we are extending It may be possible to change the implementation, so that we figure this out at run-time. At run-time we do know whether we are extending |
Hi @bblommers ! Have you had any time to look into this since this issue was last updated ? :) |
Not really @Seluj78 - I haven't found a good solution to this problem yet |
I understand. For now I guess I will have to decorate each class individually :/ Although if you do find any idea on how to solve this, I'd love to hear it! I am certain it would be a really appreciated feature for unit test users 😉 |
I'm primarily referencing this Class Decorator piece of documentation. This leads me to believe that state created or modified in
setUp(self):
will persist through tests. I run that code and it looks great.Please let me know if this is a fundamental Python or unittest misunderstanding, but here is my snippet:
Expected: I expect that the bucket we create as part of the
setUp
method will persist into thetest_bug
method.Actual: This test fails - we see 0 buckets returned during execution of
test_bug
.Version: I have tried this in both 1.3.14 and the most recent 3.1.1 with similar results.
Thank you for any guidance! Appreciate working with
moto
so far, slightly confused on by this particular behavior.The text was updated successfully, but these errors were encountered: