| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
This pull request updates system and unit tests for the BigQuery client and magics. Key changes include catching NotFound exceptions during tag deletion in system tests, switching to IPython.core.interactiveshell, making the local magics context fixture run automatically, and refactoring several tests to use parenthesized context managers. The review feedback highlights that parenthesized context managers will cause a SyntaxError in Python 3.8 environments, which are still supported by this package. Additionally, the reviewer noted that manually resetting credentials in test_context_with_default_credentials is redundant due to the updated autouse fixture, and suggested renaming test_context_fallback_when_bigquery_magics_none to better describe its purpose.
Sorry, something went wrong.
| with ( | ||
| run_query_patch as run_query_mock, | ||
| bqstorage_client_patch, | ||
| warnings.catch_warnings(record=True) as warned, | ||
| ): |
There was a problem hiding this comment.
Using parenthesized context managers (e.g., with (A, B):) is a feature introduced in Python 3.9. Since this package supports Python 3.8, using this syntax will result in a SyntaxError on Python 3.8 environments. To maintain backwards compatibility, please use standard line continuation with backslashes.
with run_query_patch as run_query_mock, \
bqstorage_client_patch, \
warnings.catch_warnings(record=True) as warned:
Sorry, something went wrong.
| with ( | ||
| pytest.raises(OSError), | ||
| client_query_patch as client_query_mock, | ||
| default_patch, | ||
| close_transports_patch as close_transports, | ||
| ): |
There was a problem hiding this comment.
Using parenthesized context managers (e.g., with (A, B):) is a feature introduced in Python 3.9. Since this package supports Python 3.8, using this syntax will result in a SyntaxError on Python 3.8 environments. To maintain backwards compatibility, please use standard line continuation with backslashes.
with pytest.raises(OSError), \
client_query_patch as client_query_mock, \
default_patch, \
close_transports_patch as close_transports:
Sorry, something went wrong.
| with ( | ||
| pytest.raises(NameError, match=r".*custom_query does not exist.*"), | ||
| run_query_patch as run_query_mock, | ||
| ): |
There was a problem hiding this comment.
Using parenthesized context managers (e.g., with (A, B):) is a feature introduced in Python 3.9. Since this package supports Python 3.8, using this syntax will result in a SyntaxError on Python 3.8 environments. To maintain backwards compatibility, please use standard line continuation with backslashes.
with pytest.raises(NameError, match=r".*custom_query does not exist.*"), \
run_query_patch as run_query_mock:
Sorry, something went wrong.
| with ( | ||
| pytest.raises(NameError, match=r"(?i).*missing query variable name.*"), | ||
| run_query_patch as run_query_mock, | ||
| ): |
There was a problem hiding this comment.
Using parenthesized context managers (e.g., with (A, B):) is a feature introduced in Python 3.9. Since this package supports Python 3.8, using this syntax will result in a SyntaxError on Python 3.8 environments. To maintain backwards compatibility, please use standard line continuation with backslashes.
with pytest.raises(NameError, match=r"(?i).*missing query variable name.*"), \
run_query_patch as run_query_mock:
Sorry, something went wrong.
| with ( | ||
| pytest.raises(TypeError, match=r".*must be a string or a bytes-like.*"), | ||
| run_query_patch as run_query_mock, | ||
| ): |
There was a problem hiding this comment.
Using parenthesized context managers (e.g., with (A, B):) is a feature introduced in Python 3.9. Since this package supports Python 3.8, using this syntax will result in a SyntaxError on Python 3.8 environments. To maintain backwards compatibility, please use standard line continuation with backslashes.
with pytest.raises(TypeError, match=r".*must be a string or a bytes-like.*"), \
run_query_patch as run_query_mock:
Sorry, something went wrong.
| with ( | ||
| pytest.raises(OSError), | ||
| create_dataset_if_necessary_patch, | ||
| close_transports_patch as close_transports, | ||
| ): |
There was a problem hiding this comment.
Using parenthesized context managers (e.g., with (A, B):) is a feature introduced in Python 3.9. Since this package supports Python 3.8, using this syntax will result in a SyntaxError on Python 3.8 environments. To maintain backwards compatibility, please use standard line continuation with backslashes.
with pytest.raises(OSError), \
create_dataset_if_necessary_patch, \
close_transports_patch as close_transports:
Sorry, something went wrong.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
| will be created the first time it is called | ||
| """ | ||
| magics.context._credentials = None | ||
| magics.context._project = None |
There was a problem hiding this comment.
non-rhetorical question here: why set these variables to None at the start of the function body? Based on the name of the test, I think this test is for the default values, so we shouldn't alter those values before the assertions
Sorry, something went wrong.
There was a problem hiding this comment.
Good catch. These variables were being cleared because the autouse=True fixture (use_local_mgaics_context) pre-populates magics.context with mock credentials for auth isolation. To verify genuine default behavior without altering private attributes, I have updated the test to inject a fresh magics.Context() via monkeypatch.setattr(magics, "context", magics.Context()).
Sorry, something went wrong.
There was a problem hiding this comment.
Ah, sorry! I think your original approach was correct after I took a closer look at the test body. This function aims to test if the credentials and project would be automatically loaded if they were None.
In that case, we should adopt your previous version but with an updated test name, maybe something like "test_context_loads_credentials_and_project_if_none_are_provided".
Sorry, something went wrong.
There was a problem hiding this comment.
The test name can also be test_context_resolves_unset_credentials_and_project. Your call.
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for following up! I've adopted your suggested name test_context_resolves_unset_credentials_and_project, which makes the test's intent much clearer
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Following the merge of PR #17953 for the socket leak fix, this PR focuses on the remaining orthogonal test and fixture hardening fixes:
Related: b/540939659 🦕