Skip to main content

A pytest plugin that runs cpplint style checking on C/C++ source files

Project description

pytest-cpplint

CI PyPI Python License

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_cpplint-0.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_cpplint-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

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

Hashes for pytest_cpplint-0.1.0.tar.gz
Algorithm Hash digest
SHA256 53b7cd8a2cf2e71cc1f5ef04e04912bab1cb5d0a8367d41dfe6b08ed98a36949
MD5 cbf564613b40f81d62f06a579821e7c2
BLAKE2b-256 88058da3643fe1c4e9cc103ac5739638fa9845cd0e0a2b74353582b420877ba5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_cpplint-0.1.0.tar.gz:

Publisher: release.yml on alexdej/pytest-cpplint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pytest_cpplint-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93a5342ca1fb95a059fee6e286798465533c9f2111cc0b1dc8182f723371aa68
MD5 b99e1e16cb5d23506735ff620caa5c35
BLAKE2b-256 9640f40ce41e0a194a2b44b23391c2c3ac0cd79ca67bac687e4b9c8e27f89b0f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_cpplint-0.1.0-py3-none-any.whl:

Publisher: release.yml on alexdej/pytest-cpplint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page