A pytest plugin to use sqlfluff to enable format checking of sql files.
Features
Tests any sql files found in project.
Leverages existing sqlfluff configurations.
Skips unchanged sql files.
Requirements
Python 3.7+
sqlfluff 1.0.0+
Installation
You can install pytest-sqlfluff via pip from PyPI:
$ pip install pytest-sqlfluff
Usage
Out of the box, you can run pytest-sqlfluff as argument to pytest:
$ pytest --sqlfluff ====================================== test session starts ====================================== platform darwin -- Python 3.9.6, pytest-7.2.0, pluggy-1.0.0 rootdir: /code/github.com/prsutherland/pytest-sqlfluff plugins: sqlfluff-0.1.0 collected 1 item tests/file.sql . [100%] ======================================= 1 passed in 0.45s =======================================
To configure your sqlfluff linting, use the standard sqlfluff configuration mechanisms. At the very least, you’ll likely need to set the dialect.:
[sqlfluff] dialect = postgres ...
Contributing
Contributions are very welcome. Tests can be run with pytest, please ensure the coverage at least stays the same before you submit a pull request.
To get started:
$ git clone https://github.com/prsutherland/pytest-sqlfluff.git $ cd pytest-sqlfluff $ poetry install
Run tests:
$ poetry run pytest
License
Distributed under the terms of the MIT license, “pytest-sqlfluff” is free and open source software
Issues
If you encounter any problems, please file an issue along with a detailed description.
Metadata
Release files for pytest-sqlfluff 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_sqlfluff-0.1.1.tar.gz | 4.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_sqlfluff-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.5 kB
Release files / pytest_sqlfluff-0.1.1.tar.gz
| Download URL | pytest_sqlfluff-0.1.1.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
405deee6f6ddc067a8802f8a033da2a839483c09fb29a6ba9027126625f9b3a7
|
|
BLAKE2b-256 checksum How to use checksums |
b10cc8533b8fbcdbbfaef77339a818b066e73dbf71ece47e4559bd0f3c1aad16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.9.6 Darwin/22.1.0
|
Release files / pytest_sqlfluff-0.1.1-py3-none-any.whl
| Download URL | pytest_sqlfluff-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a395b25a6202f4f2352e649fb227964e9cdc9f0392ae21cb15fa2817134c03cb
|
|
BLAKE2b-256 checksum How to use checksums |
ac66f1fc33f67cfcf4e79d2724198e186ccf2020dc87961407f0073153b50659
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.9.6 Darwin/22.1.0
|