test: Add DBAPI 2.0 compliance test suite#16158
test: Add DBAPI 2.0 compliance test suite#16158bhatt4982 wants to merge 1 commit intodbapi-driver-1from
Conversation
…, SQL factory, helper utilities, and nox integration.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the testing infrastructure by introducing a robust DBAPI 2.0 compliance test suite. The new tests are designed to verify that the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a DBAPI 2.0 compliance test suite, which is a great addition for ensuring driver compatibility. The changes include a new nox session for running these tests, a base test class, a SQL factory for generating test data, and helper utilities. My review focuses on improving the robustness and correctness of the new test infrastructure. I've identified a critical issue in the nox configuration that would prevent the tests from running correctly, and a couple of medium-severity issues related to code robustness and error handling in the test helpers and base class.
| MODE, | ||
| f"--junitxml=compliance_{session.python}_sponge_log.xml", | ||
| *test_paths, | ||
| env={}, |
There was a problem hiding this comment.
The test process requires the SPANNER_EMULATOR_HOST and TEST_DIALECT environment variables, but they are not being passed to session.run. An empty env dictionary is provided, which means the test environment will not have these crucial variables set, causing the tests to fail. You should pass these variables from the nox environment to the test execution environment.
env={
"SPANNER_EMULATOR_HOST": os.environ["SPANNER_EMULATOR_HOST"],
"TEST_DIALECT": os.environ.get("TEST_DIALECT", "GoogleSQL"),
},|
|
||
|
|
||
| def setup_test_env() -> None: | ||
| print(f"Set SPANNER_EMULATOR_HOST to {os.environ['SPANNER_EMULATOR_HOST']}") |
There was a problem hiding this comment.
Using os.environ['SPANNER_EMULATOR_HOST'] can raise a KeyError if the environment variable is not set. Although the nox session checks for this, running tests manually without nox could lead to a crash. It's safer to use the module-level SPANNER_EMULATOR_HOST variable, which is already populated using os.environ.get() and is available in the scope of this function.
| print(f"Set SPANNER_EMULATOR_HOST to {os.environ['SPANNER_EMULATOR_HOST']}") | |
| print(f"Set SPANNER_EMULATOR_HOST to {SPANNER_EMULATOR_HOST}") |
| except Exception: | ||
| pass |
There was a problem hiding this comment.
test: Add DBAPI 2.0 compliance test suite including a base test class, SQL factory, helper utilities, and nox integration.
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #16120 🦕