GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |
GeezerVison is showing github.com — fix: restore and correct test_discovery_http_is_closed (issue #2757) by codeXsidd · Pull Request #2843 · googleapis/google-api-python-client ConversationSummaryRestores the est_discovery_http_is_closed test that has been dead code since September 2020, and corrects it to be syntactically valid and actually executable by pytest. ProblemSince commit 98888da (Sept 2020), ests/test_discovery.py contained two separate definitions of class Discovery(unittest.TestCase). Python silently overwrites the first class definition with the second, so all tests in the first block—including est_discovery_http_is_closed—were never collected or run by pytest. Additionally, the original test body was broken:
Solution
Testing
Related IssueCloses #2757
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> The test was accidentally dead code since Sept 2020 (commit 98888da) because it was defined in a duplicate class Discovery(unittest.TestCase) block at line 498, which Python silently overwrote with the active class definition at the bottom of the file. The test was therefore never collected or executed by pytest. Additionally, the original test body was syntactically broken: it called http.close.assert_called_once() on a plain HttpMock whose close attribute is a regular function, not a mock object, so the method call would raise AttributeError if ever run. Changes: - Remove the duplicate/shadowed class Discovery block that contained only the broken test skeleton. - Add a corrected est_discovery_http_is_closed inside the active Discovery class (the one that is actually collected by pytest). - Use @mock.patch('httplib2.Http') to intercept the internally-created HTTP client that �uild() creates when no http= argument is passed. - Use @mock.patch('google.auth.default') to avoid requiring real Application Default Credentials in CI. - Assert mock_http.close.assert_called_once() to verify that �uild() closes the temporary discovery HTTP client after use, preventing socket/connection leaks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code ReviewThis pull request adds support for retrying 400 Bad Request errors (specifically for 'failedPrecondition' and 'preconditionFailed' reasons) in
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page.
codeXsidd
commented
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi team! This PR fixes the shadowed The duplicate The fix:
All 38 tests in
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. This branch has not been deployedNo deployments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reviewers1 more reviewerAt least 1 approving review is required to merge this pull request. Uh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
size: m
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. test: connection leak test test_discovery_http_is_closed is shadowed and syntactically invalidUh oh!
There was an error while loading. Please reload this page. Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later. | |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |