Skip to content

feat(gizmosql): add GizmoSQL database fixture#108

Merged
cofin merged 12 commits intomainfrom
feat/gizmosql
Jan 20, 2026
Merged

feat(gizmosql): add GizmoSQL database fixture#108
cofin merged 12 commits intomainfrom
feat/gizmosql

Conversation

@cofin
Copy link
Member

@cofin cofin commented Jan 18, 2026

Summary

  • Add pytest fixture support for GizmoSQL, a high-performance SQL server built on Apache Arrow Flight SQL with DuckDB/SQLite backends
  • Add GizmoSQLService dataclass with username, password, and uri property for TLS connections
  • Add gizmosql_service and gizmosql_connection fixtures
  • Support server-only xdist isolation (DuckDB doesn't support multiple databases per instance)
  • Add documentation with usage examples

cofin added 12 commits January 18, 2026 15:21
Add pytest fixture support for GizmoSQL, a high-performance SQL server
built on Apache Arrow Flight SQL with DuckDB/SQLite backends.

- Add GizmoSQLService with username, password, and uri property
- Add gizmosql_service and gizmosql_connection fixtures
- Support TLS connections with self-signed certificate handling
- Add server-only xdist isolation (DuckDB doesn't support multiple DBs)
- Add documentation with usage examples
- Add comprehensive tests
- Add pytest_plugins = ["pytest_databases"] to all database modules for
  fixture discovery in pytest 9.0+ subprocess test environments
- Move docker compose utilities from __init__.py to _compose.py to fix
  RUF067 (non-empty init module) lint errors
- Fix B901 (return in generator) in _service.py pytest_sessionfinish hook
Pytest 9.0+ enforces strict 1-to-1 mapping between plugin objects and
registered names. Using pytest_plugins declarations in test templates
conflicts with the entry point registration.

Changes:
- Remove pytest_plugins declarations from source database modules
- Simplify test templates to only declare the database-specific plugin
- Add -p pytest_databases CLI arg to all runpytest() calls to force
  early plugin registration via the entry point

This ensures docker_service fixture is available before database modules
load, mimicking real-world installed usage.
When pytest_plugins declares a submodule (e.g., pytest_databases.docker.bigquery),
Python imports the parent package first. With an empty __init__.py, the fixtures
from _service.py weren't available even with -p pytest_databases because pytest
treats the already-imported package as the plugin module.

This fix makes __init__.py import and re-export the fixtures so they are
available regardless of import order.
- Change xdist_gizmosql_isolation_level default from "server" to "database"
  to prevent container double-cleanup errors in pytester tests
- Use runpytest_subprocess for azure_blob tests to avoid PyO3/cryptography
  "may only be initialized once per interpreter process" error
The pytest_sessionfinish hook is registered via the entry point
(pytest_databases._service). Re-exporting it from __init__.py could
cause duplicate hook registration or cleanup issues.
…n database plugin tests.

Use subprocess mode for all pytester tests to isolate native extensions
(grpc, pymssql, cryptography, etc.) from the main pytest process. This
prevents segfaults during Python interpreter shutdown caused by native
extension cleanup conflicts.
All pytester tests now use runpytest_subprocess() instead of runpytest():
1. Tests using pytest-xdist (-n flag) need subprocess mode
2. Native extensions (grpc, cryptography, pymssql) can cause segfaults
   during Python interpreter shutdown if loaded in main process
3. pytest 9.0+ plugin discovery works more reliably in subprocess mode

Also reverts unnecessary refactoring of docker/__init__.py and __init__.py
…orts and comments in tests, and add VS Code launch and settings configurations.
@cofin cofin requested a review from provinzkraut January 19, 2026 13:16
@provinzkraut
Copy link
Member

Should we test against different pytest versions as well? Might blow up our test suite a bit but.. If there's breaking changes, we should test compatibility somehow, otherwise stuff might break.

@cofin
Copy link
Member Author

cofin commented Jan 19, 2026

Should we test against different pytest versions as well? Might blow up our test suite a bit but.. If there's breaking changes, we should test compatibility somehow, otherwise stuff might break.

yeah - if we can improve the testing, i think we should. I'll look at adding in multi-versions of pytest in the CI hook.

Opened associated issue here

@cofin cofin merged commit 264d526 into main Jan 20, 2026
15 checks passed
@cofin cofin deleted the feat/gizmosql branch January 20, 2026 14:46
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.

2 participants