Skip to content

fix(testing): close helper clients and load fixtures#10

Merged
hampsterx merged 1 commit into
masterfrom
test/testing-helper-fixtures
Jun 19, 2026
Merged

fix(testing): close helper clients and load fixtures#10
hampsterx merged 1 commit into
masterfrom
test/testing-helper-fixtures

Conversation

@hampsterx

@hampsterx hampsterx commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • Close the httpx clients created by make_client and make_async_client when the returned Snowflake clients are closed
  • Load shipped pytest fixtures from tests/conftest.py when pytest11 entry points are unavailable
  • Avoid duplicate plugin registration when the package is installed and pytest has already loaded the entry point
  • Cover sync and async helper close behavior in tests/test_testing.py

Review

  • Local static checks passed
  • Local committed-diff review found no issues
  • External Claude/Kimi review skipped: escalation policy blocked sending repository diff context to external services

Changes

  • snowflake_sql_api/testing.py: make helper-created sync and async httpx clients close with returned clients
  • tests/conftest.py: conditionally load shipped pytest fixtures outside installed pytest11 entry point path
  • tests/test_testing.py: assert sync and async helper-created httpx clients are closed

Test plan

  • /tmp/snowflake-sql-api-venv/bin/coverage run -m pytest (191 passed, 5 skipped)
  • /tmp/snowflake-sql-api-venv/bin/coverage report (94%)
  • /tmp/snowflake-sql-api-venv/bin/ruff check snowflake_sql_api tests
  • /tmp/snowflake-sql-api-venv/bin/black --check snowflake_sql_api tests
  • /tmp/snowflake-sql-api-venv/bin/mypy snowflake_sql_api
  • pre-commit run --all-files with SKIP=black; direct black passed

Summary by CodeRabbit

  • Tests

    • Enhanced client shutdown behavior verification to ensure proper resource cleanup.
  • Chores

    • Improved testing fixture loading reliability in environments without automatic plugin discovery.

- Close the httpx clients created by make_client and make_async_client when the returned Snowflake clients are closed
- Load shipped pytest fixtures from tests/conftest.py when pytest11 entry points are unavailable
- Avoid duplicate plugin registration when the package is installed and pytest has already loaded the entry point
- Cover sync and async helper close behavior in tests/test_testing.py
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 445453c4-48c9-4f1a-b955-5db67f9d505e

📥 Commits

Reviewing files that changed from the base of the PR and between 3863b3c and 55fbc09.

📒 Files selected for processing (3)
  • snowflake_sql_api/testing.py
  • tests/conftest.py
  • tests/test_testing.py

📝 Walkthrough

Walkthrough

make_client and make_async_client in testing.py now assign the constructed client to a local variable and explicitly set client._transport._owns_client = True before returning, enabling proper shutdown of the underlying httpx client. Tests gain is_closed assertions, and conftest.py adds a plugin-discovery fallback.

Changes

Transport Ownership and Closure Verification

Layer / File(s) Summary
Transport ownership flag in make_client / make_async_client
snowflake_sql_api/testing.py
Both factory functions now store the constructed client in a local variable and set client._transport._owns_client = True before returning, so the transport closes its own httpx client during shutdown.
is_closed assertions and pytest plugin fallback
tests/test_testing.py, tests/conftest.py
Adds assert client._transport._client.is_closed after close() and aclose() calls. Adds a pytest_configure hook that imports snowflake_sql_api.testing when the pytest11 entry point is not already registered.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Possibly related PRs

  • hampsterx/snowflake-sql-api#2: Introduced the snowflake_sql_api.testing module with make_client/make_async_client factories and the pytest fixtures that this PR extends with ownership and closure behavior.

Poem

🐇 Hop hop, the transport now knows who it owns,
No orphaned clients left to wander alone.
_owns_client = True, a flag proudly set,
Close and aclose — confirmed closed, no regret!
The plugin finds itself when discovery strays,
All tidy and shut in the most rabbit ways. 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: fixing helper clients to close properly and loading fixtures conditionally in tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/testing-helper-fixtures

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hampsterx hampsterx merged commit abf6202 into master Jun 19, 2026
7 checks passed
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