Skip to content
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

docs(testing): update code samples in ops.testing from unittest to pytest style #1157

Merged
merged 7 commits into from
Mar 25, 2024

Conversation

IronCore864
Copy link
Contributor

Since we are encouraging charm tests to be written with pytest, we should use that in test code examples in ops.testing.

Only code samples from ops/testing.py are updated, other files/test cases are not updated.

Closes #1154.

@IronCore864 IronCore864 marked this pull request as ready for review March 21, 2024 10:18
Copy link
Contributor

@tonyandrewmeyer tonyandrewmeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! A couple of questions about seemingly no-op indentation changes, and a suggestion about simplifying one of the examples.

ops/testing.py Show resolved Hide resolved
ops/testing.py Show resolved Hide resolved
ops/testing.py Outdated Show resolved Hide resolved
ops/testing.py Outdated Show resolved Hide resolved
CHANGES.md Show resolved Hide resolved
Copy link
Contributor

@tonyandrewmeyer tonyandrewmeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think this approach works nicely, thanks!

One small suggestion, and one place where I think the indentation isn't right.

CHANGES.md Show resolved Hide resolved
ops/testing.py Outdated Show resolved Hide resolved
ops/testing.py Show resolved Hide resolved
ops/testing.py Outdated Show resolved Hide resolved
Copy link
Contributor

@tonyandrewmeyer tonyandrewmeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks; looks good!

@tonyandrewmeyer
Copy link
Contributor

While working on another ticket, I noticed that there's also this unittest style doc in testing.py that should be updated as well.

@benhoyt
Copy link
Collaborator

benhoyt commented Mar 25, 2024

I noticed that there's also this unittest style doc in testing.py that should be updated as well.

Yeah, it would be nice if we could just tweak the text there to be more general. Something like: "Always call harness.cleanup() after a test completes (normally this is done within a pytest fixture)."

Copy link
Collaborator

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just get that tweak to the cleanup docstring in and then this is good to go!

@IronCore864 IronCore864 merged commit e2a7f7d into canonical:main Mar 25, 2024
28 checks passed
@IronCore864 IronCore864 deleted the test-code-examples-to-pytest branch March 25, 2024 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update ops.testing/Harness test examples in docstring to pytest style
3 participants