A pytest plugin that runs cpplint style checking on C/C++ source files
Project description
pytest-cpplint
A pytest plugin that runs cpplint style checking on C/C++ source files. Each file is collected as a test item and reported as a pass or failure in the normal pytest output.
Useful for Python projects with C extension modules where you already run pytest and want cpplint findings surfaced in the same test run.
Installation
pip install pytest-cpplint
This pulls in cpplint automatically via the cpplint PyPI package.
Usage
The plugin does nothing unless explicitly enabled:
pytest --cpplint
This collects all .c, .cc, .cpp, .cxx, .h, .hpp, and .hxx files
and runs cpplint on each one. Files with findings fail; clean files pass.
PASSED src/clean.c::CPPLINT
FAILED src/buggy.c::CPPLINT
src/buggy.c:12: Lines should be <= 80 characters long [whitespace/line_length] [2]
You can combine --cpplint with your normal test run — Python tests and
cpplint items appear together in the results.
Configuration
All options go in pyproject.toml, pytest.ini, or setup.cfg under [pytest].
cpplint_args
Extra arguments forwarded to every cpplint invocation. This is the main
configuration surface — use it for --filter, --linelength, --root, and
any other cpplint flags.
With no cpplint_args, cpplint runs all of its default checks (Google C++
style guide). Use --filter to enable or disable specific categories. A good
starting configuration:
[pytest]
cpplint_args =
--linelength=120
--filter=-legal/copyright,-build/header_guard
cpplint_extensions
File extensions to collect. Default: .c .cc .cpp .cxx .h .hpp .hxx.
[pytest]
cpplint_extensions = .c .cpp .h
Markers
All cpplint items are marked with cpplint, so you can select or exclude
them with -m:
pytest --cpplint -m cpplint # only cpplint
pytest --cpplint -m "unit or cpplint" # unit tests + cpplint
pytest --cpplint -m "not cpplint" # everything except cpplint
Caching
Results are cached based on file modification time and cpplint_args. On
subsequent runs, files that previously passed are skipped. The cache is
automatically invalidated when a file is modified or cpplint_args changes.
Caching relies on pytest's built-in cache provider (the .pytest_cache directory).
If the cache provider is disabled (for example with -p no:cacheprovider), results
will not be cached and all files will be re-checked on each run.
To force a full re-check:
pytest --cpplint --cache-clear
License
MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_cpplint-0.1.0.tar.gz.
File metadata
- Download URL: pytest_cpplint-0.1.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53b7cd8a2cf2e71cc1f5ef04e04912bab1cb5d0a8367d41dfe6b08ed98a36949
|
|
| MD5 |
cbf564613b40f81d62f06a579821e7c2
|
|
| BLAKE2b-256 |
88058da3643fe1c4e9cc103ac5739638fa9845cd0e0a2b74353582b420877ba5
|
Provenance
The following attestation bundles were made for pytest_cpplint-0.1.0.tar.gz:
Publisher:
release.yml on alexdej/pytest-cpplint
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_cpplint-0.1.0.tar.gz -
Subject digest:
53b7cd8a2cf2e71cc1f5ef04e04912bab1cb5d0a8367d41dfe6b08ed98a36949 - Sigstore transparency entry: 1186975063
- Sigstore integration time:
-
Permalink:
alexdej/pytest-cpplint@f9e0d96dd10fe38a76c236faaa1b4fb8e6b24383 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/alexdej
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f9e0d96dd10fe38a76c236faaa1b4fb8e6b24383 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_cpplint-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pytest_cpplint-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93a5342ca1fb95a059fee6e286798465533c9f2111cc0b1dc8182f723371aa68
|
|
| MD5 |
b99e1e16cb5d23506735ff620caa5c35
|
|
| BLAKE2b-256 |
9640f40ce41e0a194a2b44b23391c2c3ac0cd79ca67bac687e4b9c8e27f89b0f
|
Provenance
The following attestation bundles were made for pytest_cpplint-0.1.0-py3-none-any.whl:
Publisher:
release.yml on alexdej/pytest-cpplint
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_cpplint-0.1.0-py3-none-any.whl -
Subject digest:
93a5342ca1fb95a059fee6e286798465533c9f2111cc0b1dc8182f723371aa68 - Sigstore transparency entry: 1186975093
- Sigstore integration time:
-
Permalink:
alexdej/pytest-cpplint@f9e0d96dd10fe38a76c236faaa1b4fb8e6b24383 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/alexdej
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f9e0d96dd10fe38a76c236faaa1b4fb8e6b24383 -
Trigger Event:
push
-
Statement type: