-
Notifications
You must be signed in to change notification settings - Fork 7
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
Make Jenkins implement AbstractAsyncContextManager + Improve tests/README to use it #34
Conversation
@@ -64,7 +65,7 @@ async def close(self) -> None: | |||
await self.session.close() | |||
|
|||
|
|||
class Jenkins: | |||
class Jenkins(AbstractAsyncContextManager): |
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.
Subclassing this automatically provides the default __aenter__
method (which returns self
)
@@ -184,5 +171,3 @@ async def test_make_jenkins_version(jenkins, aiohttp_mock): | |||
) | |||
version = await jenkins.get_version() | |||
assert version == JenkinsVersion(major=2, minor=346, patch=1, build=4) | |||
|
|||
await jenkins.close() |
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.
This seemed like a stray call to close
and tests passed without it
@pbelskiy Would this be good to merge along with a version bump? 👀 |
962d52c
to
974caab
Compare
974caab
to
ee64a8a
Compare
dd71226
to
4c10e19
Compare
I was using this for a project, and I didn't like having to write
try...finally: await jenkins.close()
.This is the idiomatic way to setup/close resources such as this, and I'd love to see this merged/published to pypi if possible! Tests all pass locally (including with
3.73.8, the minimum supported version of python for this project).