A pytest plugin to use sqlfluff to enable format checking of sql files.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytest_sqlfluff-0.1.1.tar.gz
.
File metadata
- Download URL: pytest_sqlfluff-0.1.1.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.9.6 Darwin/22.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 405deee6f6ddc067a8802f8a033da2a839483c09fb29a6ba9027126625f9b3a7 |
|
MD5 | 00449a41c25851c8ba7d19c1a9a5d5d6 |
|
BLAKE2b-256 | b10cc8533b8fbcdbbfaef77339a818b066e73dbf71ece47e4559bd0f3c1aad16 |
File details
Details for the file pytest_sqlfluff-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: pytest_sqlfluff-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.9.6 Darwin/22.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a395b25a6202f4f2352e649fb227964e9cdc9f0392ae21cb15fa2817134c03cb |
|
MD5 | 00604d80bc55168d54e4941a518dbe51 |
|
BLAKE2b-256 | ac66f1fc33f67cfcf4e79d2724198e186ccf2020dc87961407f0073153b50659 |