Pytest BQ
This is a pytest plugin in similar vein to pytest-postgres and pytest-kafka. It runs a local version of bigquery that you can use throughout your test suite.
This would have been much more painful without Mirakuru and bigquery-emulator; this is a simple wrapper around those tools.
Installation
This tool requires you to have a copy of the bigquery-emulator binary somewhere on your path.
Depending upon your architecture you'll need a different version of the tool.
wget https://github.com/goccy/bigquery-emulator/releases/download/v0.6.1/bigquery-emulator-linux-amd64
mv bigquery-emulator-linux-amd64 /usr/local/bin/bigquery-emulator
To install this library:
pip install pytest-bq
Demo
# conftest.py
from pytest_bq.factories import client as bq_client
from pytest_bq.factories import proc as bq_process
# Create a process and a local client that targets that process.
bq_proc = bq_process.bq_proc(executable='/usr/local/bin/bigquery-emulator', project_id='test')
bqlocal = bq_client.bqlocal("bq_proc")
# tests/test_bq.py
from google.cloud import bigquery
from pytest_bq.executor.process import BQExecutor
def test_can_list_datasets(bq_proc: BQExecutor, bqlocal: bigquery.Client) -> None:
"""MVP to ensure everything works."""
test_dataset = "test_base"
bqlocal.create_dataset(test_dataset)
datasets = [x.full_dataset_id for x in bqlocal.list_datasets()]
assert test_dataset in datasets
Contributing
PRs are accepted.
# Install the dependencies with:
pip install .[test]
# Install pre-commit hooks.
pre-commit install
# Validate everything passes.
pre-commit run --all
# Run the tests.
pytest tests/
TODOs
- Validate
data_from_yamlfiles. - Tools for dummy data generation.
Metadata
Release files for pytest-bq 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytest_bq-0.0.4.tar.gz | 8.7 kB | Without provenance | Details for pytest_bq-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_bq-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for pytest_bq-0.0.4-py3-none-any.whl |
Total release size: 17.7 kB
Release files / pytest_bq-0.0.4.tar.gz
| Download URL | pytest_bq-0.0.4.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c1bc378f75474dc3b35c6808b1151415a257848116c5a4c85f4a4c7305aab6f9
|
|
BLAKE2b-256 checksum How to use checksums |
d59bc8062bcc61c35fb2b4bade04a127986929766436447c3b24cf2d44ec212b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|
Release files / pytest_bq-0.0.4-py3-none-any.whl
| Download URL | pytest_bq-0.0.4-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0182e9ad7719d971c22aaa1f6cefc418e2a84c6eb836bfc11ca480341f59320d
|
|
BLAKE2b-256 checksum How to use checksums |
c89abe6ce7015d69c8e7bd3d25f024d476eaa8c78ad8814414d4a571ee3ef9ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|
Security for pytest-bq 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.