-
Notifications
You must be signed in to change notification settings - Fork 112
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
Go all-in on using pytest instead of unittest in docs, examples, etc #1110
Comments
I chatted with Ben, and I'll get started on this issue! |
Progress tracker:
|
Cool, looks like a good start. We'll cast our eyes over those PRs. Can you please add a note or link about why #4 is blocked by charmcraft? Or is that just referring to the |
I am not too familiar with pytest but I think there's a subtle difference we need to keep in mind:
|
Creating a I'm not sure how this ends up being a tricky detail - it's essentially the same behaviour. Am I missing something here?
Can you explain what the "rolling changes" approach is? |
Right, fixtures have scope. In that case do we want to encourage function scope in the templates? Module scope is the "rolling changes" approach: in one test function you add a relation, and it is still there in the next test function. Can get messy. |
@sed-i It looks like function scope is the default, right, so as I understand it that's what the suggested templates propose? |
How are you doing this with |
I'm very curious to see how utests with pytests could look like. On one hand, it's much easier to use hypothesis with pytest. On the other hand, pytest is notorious for having too much hidden magic. |
Related to canonical/operator#1110. I kept the changes as minimal as possible. --------- Co-authored-by: Alex Batisse <alex.batisse@canonical.com>
TBH, the hidden magic is a big part of why I like |
@Batalex I'm with @sed-i here. I really like pytest's simple use of On my "articles to write" list I have this suggestion: write about my love-hate relationship with pytest - assert and test finding, yes! Magical fixtures wired up by name, no thanks! Maybe I'll write that article someday. I wish there was something like pytest but without those magical features. :-) |
Related to canonical/operator#1110. I kept the changes as minimal as possible. --------- Co-authored-by: Alex Batisse <alex.batisse@canonical.com>
Thanks for all the work on this @Batalex ! |
Pytest really makes writing tests a lot lighter and easier-to-read with plain functions and
assert foo == bar
rather thanself.assertEqual(foo, bar)
. Exemplify this in our SDK docs, API reference docs,charmcraft init
templates examples, and so on.The text was updated successfully, but these errors were encountered: