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

Fix incorrect asserts in test and ensure connections are closed #3004

Merged
merged 3 commits into from
Feb 22, 2024

Conversation

kristjanvalur
Copy link
Contributor

@kristjanvalur kristjanvalur commented Oct 13, 2023

Pull Request check-list

Please make sure to review and check all of these items:

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?
  • Was the change added to CHANGES file?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

Various error message assertions were incorrectly placed and were not testing anything.
In addition, sockets were being leaked in the tests.

@codecov-commenter
Copy link

codecov-commenter commented Oct 13, 2023

Codecov Report

Attention: 11 lines in your changes are missing coverage. Please review.

Comparison is base (2f88840) 91.84% compared to head (a9cd991) 91.83%.
Report is 8 commits behind head on master.

Files Patch % Lines
tests/test_ssl.py 47.61% 11 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3004      +/-   ##
==========================================
- Coverage   91.84%   91.83%   -0.01%     
==========================================
  Files         128      128              
  Lines       33232    33283      +51     
==========================================
+ Hits        30523    30567      +44     
- Misses       2709     2716       +7     

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

@kristjanvalur kristjanvalur marked this pull request as ready for review October 13, 2023 14:49
@kristjanvalur kristjanvalur force-pushed the kristjan/fix-ssl-tests branch from a44028d to 4cc5559 Compare October 13, 2023 14:55
Copy link
Collaborator

@dvora-h dvora-h left a comment

Choose a reason for hiding this comment

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

Just to my understanding - why is this the correct way to test it?

@kristjanvalur kristjanvalur force-pushed the kristjan/fix-ssl-tests branch from 4cc5559 to f62e35b Compare October 16, 2023 14:51
@dvora-h
Copy link
Collaborator

dvora-h commented Dec 3, 2023

@kristjanvalur I think you missed my question here, if you can, I would like to understand it.

@kristjanvalur
Copy link
Contributor Author

@kristjanvalur I think you missed my question here, if you can, I would like to understand it.

I did indeed, sorry :)

with pytest.raises(ConnectionError) as e:
            sslclient.ping()
            assert "SSL: CERTIFICATE_VERIFY_FAILED" in str(e)

The above assert will never be hit. sslclient.ping() raises a connection error and the pytest.raises context manager is exited, before execution ever gets to assert.
The correct way to examine the raised exception is to examine the contents of e.value after exiting the context manager. If just grepping for a string, then str(e) is good enough too.

see https://docs.pytest.org/en/7.1.x/reference/reference.html?highlight=raises#pytest.raises

@dvora-h
Copy link
Collaborator

dvora-h commented Feb 19, 2024

@kristjanvalur Sorry, I missed this pr. can you merge master in so I'll can merge it?

@dvora-h dvora-h added the maintenance Maintenance (CI, Releases, etc) label Feb 19, 2024
@kristjanvalur
Copy link
Contributor Author

seems unit tests runners are shaky again.

@dvora-h dvora-h merged commit d529c2a into redis:master Feb 22, 2024
46 checks passed
@kristjanvalur kristjanvalur deleted the kristjan/fix-ssl-tests branch February 26, 2024 10:08
gerzse pushed a commit to gerzse/redis-py that referenced this pull request Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Maintenance (CI, Releases, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants