Skip to content

test(bigquery-magics): make table_id parsing check version-agnostic#17562

Open
chalmerlowe wants to merge 5 commits into
mainfrom
fix/magics-table-id-test
Open

test(bigquery-magics): make table_id parsing check version-agnostic#17562
chalmerlowe wants to merge 5 commits into
mainfrom
fix/magics-table-id-test

Conversation

@chalmerlowe

@chalmerlowe chalmerlowe commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Note

These changes are at a high level unrelated. They are being submitted as a single corrective action. Separating them leads to a chicken or the egg set of failures (i.e. no one PR will pass all CI/CD tests with out the other changes).


test(bigquery-magics): make table_id parsing check version-agnostic

The unit test test_bigquery_magic_query_variable_not_identifier was asserting that a specific error message ("must be a fully-qualified ID") was in the stderr output.

However, in a recent versions of dependencies, this error message changed (depending on whether tests were run under Python 3.10 or 3.11+). There is a key term that is common to both of the error messages: table_id.

This change confirms that we get one of the two expected error messages by checking for table_id, making it compatible regardless of which runtime the tests run under.


refactor(magics): replace fragile psutil socket check with client close mock spy

The system test test_bigquery_magic was using psutil to count open sockets before and after the test to detect leaks (i.e. ensure all the system resources were released).

This approach proved to be fragile across different environments (e.g., Kokoro).

This change replaces the socket counting with a mock spy on google.cloud.bigquery.Client.close to verify that the client is explicitly closed, which is the intended mechanism for releasing system resources.


test(bigquery-magics): simplify IPython initialization in deprecation test

The unit test test_cell_magic_engine_bigframes_warning in test_deprecation.py was conditionally initializing IPython. Only one of the code paths was being exercised so we were getting a coverage issue.

This change simplifies the initialization by unconditionally calling start_ipython() and assigning the returned instance to ip ensuring a clean and consistent state for the test and avoiding the need for a conditional check.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates a unit test assertion in test_bigquery.py to check for the presence of 'table_id' instead of 'must be a fully-qualified ID' in the error output. There are no review comments, and I have no feedback to provide.

Comment thread packages/bigquery-magics/tests/unit/bigquery/test_deprecation.py
Comment thread packages/bigquery-magics/tests/unit/bigquery/test_deprecation.py Outdated
@chalmerlowe chalmerlowe marked this pull request as ready for review June 24, 2026 11:33
@chalmerlowe chalmerlowe requested review from a team as code owners June 24, 2026 11:33
@chalmerlowe chalmerlowe requested review from TrevorBergeron and removed request for a team June 24, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant