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

Updated tests to use context managers #294

Merged
merged 5 commits into from
Jul 1, 2024

Conversation

aadityasinha-dotcom
Copy link
Contributor

@aadityasinha-dotcom aadityasinha-dotcom commented Jun 24, 2024

What It Does

Resolves #288

How to Test

Review Checklist
I certify that I have:

Additional Comments

Signed-off-by: aadityasinha-dotcom <aadityasinha009@gmail.com>
Copy link

codecov bot commented Jun 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.81%. Comparing base (dd86da8) to head (3514d11).
Report is 177 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #294      +/-   ##
==========================================
+ Coverage   89.71%   89.81%   +0.09%     
==========================================
  Files          53       53              
  Lines        2674     2680       +6     
==========================================
+ Hits         2399     2407       +8     
+ Misses        275      273       -2     
Flag Coverage Δ
unittests 89.81% <100.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@pem70 pem70 left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me!

Comment on lines 14 to 15
with Console(test_profile) as console:
self.console = console
Copy link
Member

Choose a reason for hiding this comment

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

For integration tests, it doesn't work to use a with statement in the setUp block because the request.Session object gets deleted immediately before tests can run.

I think the following would work instead:

Suggested change
with Console(test_profile) as console:
self.console = console
self.console = Console(test_profile)
self.addCleanup(lambda: self.console.__exit__(None, None, None))

See https://stackoverflow.com/questions/8416208/in-python-is-there-a-good-idiom-for-using-context-managers-in-setup-teardown 😋

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, the requests.Session object gets deleted in each integeration test

Copy link
Member

@t1m0thyj t1m0thyj Jun 27, 2024

Choose a reason for hiding this comment

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

That's right, we want to delete the requests.Session object for each integration test, but need to wait until after the test runs which can be accomplished by addCleanup.

aadityasinha-dotcom and others added 2 commits June 28, 2024 18:52
Signed-off-by: aadityasinha-dotcom <aadityasinha009@gmail.com>
Copy link
Member

@zFernand0 zFernand0 left a comment

Choose a reason for hiding this comment

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

changes LGTM! 😋
just one minor comment

tests/integration/test_zos_console.py Outdated Show resolved Hide resolved
@JTonda JTonda requested review from t1m0thyj and zFernand0 July 1, 2024 15:04
aadityasinha-dotcom and others added 2 commits July 1, 2024 23:09
Co-authored-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>
Signed-off-by: Aaditya Sinha <75474786+aadityasinha-dotcom@users.noreply.github.com>
@t1m0thyj t1m0thyj merged commit be7b36a into zowe:main Jul 1, 2024
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update tests to use context managers
4 participants