pytest-cppcheck 0.1.0__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alex DeJarnatt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,152 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytest-cppcheck
3
+ Version: 0.1.2
4
+ Summary: A pytest plugin that runs cppcheck static analysis on C/C++ source files
5
+ Author-email: Alex DeJarnatt <adejarnatt@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Alex DeJarnatt
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/alexdej/pytest-cppcheck
29
+ Project-URL: Repository, https://github.com/alexdej/pytest-cppcheck
30
+ Classifier: Framework :: Pytest
31
+ Classifier: Programming Language :: Python :: 3
32
+ Classifier: Programming Language :: Python :: 3.8
33
+ Classifier: Programming Language :: Python :: 3.9
34
+ Classifier: Programming Language :: Python :: 3.10
35
+ Classifier: Programming Language :: Python :: 3.11
36
+ Classifier: Programming Language :: Python :: 3.12
37
+ Classifier: Programming Language :: Python :: 3.13
38
+ Classifier: License :: OSI Approved :: MIT License
39
+ Requires-Python: >=3.8
40
+ Description-Content-Type: text/markdown
41
+ License-File: LICENSE
42
+ Requires-Dist: pytest>=7.0
43
+ Requires-Dist: cppcheck>=1.4.0
44
+ Dynamic: license-file
45
+
46
+ # pytest-cppcheck
47
+
48
+ [![CI](https://github.com/alexdej/pytest-cppcheck/actions/workflows/ci.yml/badge.svg)](https://github.com/alexdej/pytest-cppcheck/actions/workflows/ci.yml)
49
+ [![PyPI](https://img.shields.io/pypi/v/pytest-cppcheck)](https://pypi.org/project/pytest-cppcheck/)
50
+ [![Python](https://img.shields.io/pypi/pyversions/pytest-cppcheck)](https://pypi.org/project/pytest-cppcheck/)
51
+ [![License](https://img.shields.io/pypi/l/pytest-cppcheck)](https://github.com/alexdej/pytest-cppcheck/blob/main/LICENSE)
52
+
53
+ A pytest plugin that runs [cppcheck](https://cppcheck.sourceforge.io/) static
54
+ analysis on C/C++ source files. Each file is collected as a test item and
55
+ reported as a pass or failure in the normal pytest output.
56
+
57
+ Useful for Python projects with C extension modules where you already run pytest
58
+ and want cppcheck findings surfaced in the same test run.
59
+
60
+ ## Installation
61
+
62
+ ```
63
+ pip install pytest-cppcheck
64
+ ```
65
+
66
+ This pulls in cppcheck automatically via the
67
+ [cppcheck](https://pypi.org/project/cppcheck/) PyPI package. If you prefer a
68
+ specific version, install cppcheck yourself via your system package manager
69
+ (`apt install cppcheck`, `brew install cppcheck`, etc.) — the plugin uses
70
+ whichever `cppcheck` is on PATH.
71
+
72
+ ## Usage
73
+
74
+ The plugin does nothing unless explicitly enabled:
75
+
76
+ ```
77
+ pytest --cppcheck
78
+ ```
79
+
80
+ This collects all `.c` and `.cpp` files and runs cppcheck on each one.
81
+ Files with findings fail; clean files pass.
82
+
83
+ ```
84
+ PASSED src/clean.c::CPPCHECK
85
+ FAILED src/buggy.c::CPPCHECK
86
+ src/buggy.c:42:8: error: Array 'arr[10]' accessed at index 10, which is
87
+ out of bounds. [arrayIndexOutOfBounds]
88
+ ```
89
+
90
+ You can combine `--cppcheck` with your normal test run — Python tests and
91
+ cppcheck items appear together in the results.
92
+
93
+ ## Configuration
94
+
95
+ All options go in `pyproject.toml`, `pytest.ini`, or `setup.cfg` under `[pytest]`.
96
+
97
+ ### `cppcheck_args`
98
+
99
+ Extra arguments forwarded to every cppcheck invocation. This is the main
100
+ configuration surface — use it for `--enable`, `--suppress`, and any other
101
+ cppcheck flags. The plugin always passes `--quiet` and `--error-exitcode=1`
102
+ automatically.
103
+
104
+ With no `cppcheck_args`, cppcheck runs its default checks (mostly
105
+ error-severity). Use `--enable` to broaden coverage. A good starting
106
+ configuration:
107
+
108
+ ```ini
109
+ [pytest]
110
+ cppcheck_args =
111
+ --enable=warning,style,performance,portability
112
+ --check-level=exhaustive
113
+ ```
114
+
115
+ ### `cppcheck_extensions`
116
+
117
+ File extensions to collect. Default: `.c .cpp`.
118
+
119
+ ```ini
120
+ [pytest]
121
+ cppcheck_extensions = .c .cpp .h
122
+ ```
123
+
124
+ ## Markers
125
+
126
+ All cppcheck items are marked with `cppcheck`, so you can select or exclude
127
+ them with `-m`:
128
+
129
+ ```
130
+ pytest --cppcheck -m cppcheck # only cppcheck
131
+ pytest --cppcheck -m "unit or cppcheck" # unit tests + cppcheck
132
+ pytest --cppcheck -m "not cppcheck" # everything except cppcheck
133
+ ```
134
+
135
+ ## Caching
136
+
137
+ Results are cached based on file modification time and `cppcheck_args`. On
138
+ subsequent runs, files that previously passed are skipped. The cache is
139
+ automatically invalidated when a file is modified or `cppcheck_args` changes.
140
+ Caching relies on pytest's built-in cache provider (the `.pytest_cache` directory).
141
+ If the cache provider is disabled (for example with `-p no:cacheprovider`), results
142
+ will not be cached and all files will be re-checked on each run.
143
+
144
+ To force a full re-check:
145
+
146
+ ```
147
+ pytest --cppcheck --cache-clear
148
+ ```
149
+
150
+ ## License
151
+
152
+ MIT
@@ -1,5 +1,10 @@
1
1
  # pytest-cppcheck
2
2
 
3
+ [![CI](https://github.com/alexdej/pytest-cppcheck/actions/workflows/ci.yml/badge.svg)](https://github.com/alexdej/pytest-cppcheck/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/pytest-cppcheck)](https://pypi.org/project/pytest-cppcheck/)
5
+ [![Python](https://img.shields.io/pypi/pyversions/pytest-cppcheck)](https://pypi.org/project/pytest-cppcheck/)
6
+ [![License](https://img.shields.io/pypi/l/pytest-cppcheck)](https://github.com/alexdej/pytest-cppcheck/blob/main/LICENSE)
7
+
3
8
  A pytest plugin that runs [cppcheck](https://cppcheck.sourceforge.io/) static
4
9
  analysis on C/C++ source files. Each file is collected as a test item and
5
10
  reported as a pass or failure in the normal pytest output.
@@ -59,15 +64,9 @@ configuration:
59
64
  [pytest]
60
65
  cppcheck_args =
61
66
  --enable=warning,style,performance,portability
62
- --suppress=missingIncludeSystem
63
- --suppress=normalCheckLevelMaxBranches
67
+ --check-level=exhaustive
64
68
  ```
65
69
 
66
- `missingIncludeSystem` suppresses noise about system headers that aren't
67
- available to cppcheck. `normalCheckLevelMaxBranches` suppresses an
68
- informational message that cppcheck emits on complex files and that would
69
- otherwise be reported as a failure.
70
-
71
70
  ### `cppcheck_extensions`
72
71
 
73
72
  File extensions to collect. Default: `.c .cpp`.
@@ -77,6 +76,17 @@ File extensions to collect. Default: `.c .cpp`.
77
76
  cppcheck_extensions = .c .cpp .h
78
77
  ```
79
78
 
79
+ ## Markers
80
+
81
+ All cppcheck items are marked with `cppcheck`, so you can select or exclude
82
+ them with `-m`:
83
+
84
+ ```
85
+ pytest --cppcheck -m cppcheck # only cppcheck
86
+ pytest --cppcheck -m "unit or cppcheck" # unit tests + cppcheck
87
+ pytest --cppcheck -m "not cppcheck" # everything except cppcheck
88
+ ```
89
+
80
90
  ## Caching
81
91
 
82
92
  Results are cached based on file modification time and `cppcheck_args`. On
@@ -4,8 +4,13 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pytest-cppcheck"
7
- version = "0.1.0"
7
+ version = "0.1.2"
8
8
  description = "A pytest plugin that runs cppcheck static analysis on C/C++ source files"
9
+ readme = "README.md"
10
+ license = {file = "LICENSE"}
11
+ authors = [
12
+ { name = "Alex DeJarnatt", email = "adejarnatt@gmail.com" },
13
+ ]
9
14
  requires-python = ">=3.8"
10
15
  dependencies = [
11
16
  "pytest>=7.0",
@@ -14,9 +19,19 @@ dependencies = [
14
19
  classifiers = [
15
20
  "Framework :: Pytest",
16
21
  "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.8",
23
+ "Programming Language :: Python :: 3.9",
24
+ "Programming Language :: Python :: 3.10",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ "Programming Language :: Python :: 3.13",
17
28
  "License :: OSI Approved :: MIT License",
18
29
  ]
19
30
 
31
+ [project.urls]
32
+ Homepage = "https://github.com/alexdej/pytest-cppcheck"
33
+ Repository = "https://github.com/alexdej/pytest-cppcheck"
34
+
20
35
  [project.entry-points."pytest11"]
21
36
  cppcheck = "pytest_cppcheck.plugin"
22
37
 
@@ -30,6 +30,7 @@ def pytest_addoption(parser):
30
30
 
31
31
 
32
32
  def pytest_configure(config):
33
+ config.addinivalue_line("markers", "cppcheck: cppcheck static analysis test")
33
34
  if not config.getoption("cppcheck"):
34
35
  return
35
36
  cache = getattr(config, "cache", None)
@@ -60,7 +61,9 @@ class CppcheckError(Exception):
60
61
 
61
62
  class CppcheckFile(pytest.File):
62
63
  def collect(self):
63
- yield CppcheckItem.from_parent(self, name="CPPCHECK")
64
+ item = CppcheckItem.from_parent(self, name="CPPCHECK")
65
+ item.add_marker(pytest.mark.cppcheck)
66
+ yield item
64
67
 
65
68
 
66
69
  class CppcheckItem(pytest.Item):
@@ -0,0 +1,152 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytest-cppcheck
3
+ Version: 0.1.2
4
+ Summary: A pytest plugin that runs cppcheck static analysis on C/C++ source files
5
+ Author-email: Alex DeJarnatt <adejarnatt@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Alex DeJarnatt
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/alexdej/pytest-cppcheck
29
+ Project-URL: Repository, https://github.com/alexdej/pytest-cppcheck
30
+ Classifier: Framework :: Pytest
31
+ Classifier: Programming Language :: Python :: 3
32
+ Classifier: Programming Language :: Python :: 3.8
33
+ Classifier: Programming Language :: Python :: 3.9
34
+ Classifier: Programming Language :: Python :: 3.10
35
+ Classifier: Programming Language :: Python :: 3.11
36
+ Classifier: Programming Language :: Python :: 3.12
37
+ Classifier: Programming Language :: Python :: 3.13
38
+ Classifier: License :: OSI Approved :: MIT License
39
+ Requires-Python: >=3.8
40
+ Description-Content-Type: text/markdown
41
+ License-File: LICENSE
42
+ Requires-Dist: pytest>=7.0
43
+ Requires-Dist: cppcheck>=1.4.0
44
+ Dynamic: license-file
45
+
46
+ # pytest-cppcheck
47
+
48
+ [![CI](https://github.com/alexdej/pytest-cppcheck/actions/workflows/ci.yml/badge.svg)](https://github.com/alexdej/pytest-cppcheck/actions/workflows/ci.yml)
49
+ [![PyPI](https://img.shields.io/pypi/v/pytest-cppcheck)](https://pypi.org/project/pytest-cppcheck/)
50
+ [![Python](https://img.shields.io/pypi/pyversions/pytest-cppcheck)](https://pypi.org/project/pytest-cppcheck/)
51
+ [![License](https://img.shields.io/pypi/l/pytest-cppcheck)](https://github.com/alexdej/pytest-cppcheck/blob/main/LICENSE)
52
+
53
+ A pytest plugin that runs [cppcheck](https://cppcheck.sourceforge.io/) static
54
+ analysis on C/C++ source files. Each file is collected as a test item and
55
+ reported as a pass or failure in the normal pytest output.
56
+
57
+ Useful for Python projects with C extension modules where you already run pytest
58
+ and want cppcheck findings surfaced in the same test run.
59
+
60
+ ## Installation
61
+
62
+ ```
63
+ pip install pytest-cppcheck
64
+ ```
65
+
66
+ This pulls in cppcheck automatically via the
67
+ [cppcheck](https://pypi.org/project/cppcheck/) PyPI package. If you prefer a
68
+ specific version, install cppcheck yourself via your system package manager
69
+ (`apt install cppcheck`, `brew install cppcheck`, etc.) — the plugin uses
70
+ whichever `cppcheck` is on PATH.
71
+
72
+ ## Usage
73
+
74
+ The plugin does nothing unless explicitly enabled:
75
+
76
+ ```
77
+ pytest --cppcheck
78
+ ```
79
+
80
+ This collects all `.c` and `.cpp` files and runs cppcheck on each one.
81
+ Files with findings fail; clean files pass.
82
+
83
+ ```
84
+ PASSED src/clean.c::CPPCHECK
85
+ FAILED src/buggy.c::CPPCHECK
86
+ src/buggy.c:42:8: error: Array 'arr[10]' accessed at index 10, which is
87
+ out of bounds. [arrayIndexOutOfBounds]
88
+ ```
89
+
90
+ You can combine `--cppcheck` with your normal test run — Python tests and
91
+ cppcheck items appear together in the results.
92
+
93
+ ## Configuration
94
+
95
+ All options go in `pyproject.toml`, `pytest.ini`, or `setup.cfg` under `[pytest]`.
96
+
97
+ ### `cppcheck_args`
98
+
99
+ Extra arguments forwarded to every cppcheck invocation. This is the main
100
+ configuration surface — use it for `--enable`, `--suppress`, and any other
101
+ cppcheck flags. The plugin always passes `--quiet` and `--error-exitcode=1`
102
+ automatically.
103
+
104
+ With no `cppcheck_args`, cppcheck runs its default checks (mostly
105
+ error-severity). Use `--enable` to broaden coverage. A good starting
106
+ configuration:
107
+
108
+ ```ini
109
+ [pytest]
110
+ cppcheck_args =
111
+ --enable=warning,style,performance,portability
112
+ --check-level=exhaustive
113
+ ```
114
+
115
+ ### `cppcheck_extensions`
116
+
117
+ File extensions to collect. Default: `.c .cpp`.
118
+
119
+ ```ini
120
+ [pytest]
121
+ cppcheck_extensions = .c .cpp .h
122
+ ```
123
+
124
+ ## Markers
125
+
126
+ All cppcheck items are marked with `cppcheck`, so you can select or exclude
127
+ them with `-m`:
128
+
129
+ ```
130
+ pytest --cppcheck -m cppcheck # only cppcheck
131
+ pytest --cppcheck -m "unit or cppcheck" # unit tests + cppcheck
132
+ pytest --cppcheck -m "not cppcheck" # everything except cppcheck
133
+ ```
134
+
135
+ ## Caching
136
+
137
+ Results are cached based on file modification time and `cppcheck_args`. On
138
+ subsequent runs, files that previously passed are skipped. The cache is
139
+ automatically invalidated when a file is modified or `cppcheck_args` changes.
140
+ Caching relies on pytest's built-in cache provider (the `.pytest_cache` directory).
141
+ If the cache provider is disabled (for example with `-p no:cacheprovider`), results
142
+ will not be cached and all files will be re-checked on each run.
143
+
144
+ To force a full re-check:
145
+
146
+ ```
147
+ pytest --cppcheck --cache-clear
148
+ ```
149
+
150
+ ## License
151
+
152
+ MIT
@@ -1,3 +1,4 @@
1
+ LICENSE
1
2
  README.md
2
3
  pyproject.toml
3
4
  src/pytest_cppcheck/__init__.py
@@ -1,10 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: pytest-cppcheck
3
- Version: 0.1.0
4
- Summary: A pytest plugin that runs cppcheck static analysis on C/C++ source files
5
- Classifier: Framework :: Pytest
6
- Classifier: Programming Language :: Python :: 3
7
- Classifier: License :: OSI Approved :: MIT License
8
- Requires-Python: >=3.8
9
- Requires-Dist: pytest>=7.0
10
- Requires-Dist: cppcheck>=1.4.0
@@ -1,10 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: pytest-cppcheck
3
- Version: 0.1.0
4
- Summary: A pytest plugin that runs cppcheck static analysis on C/C++ source files
5
- Classifier: Framework :: Pytest
6
- Classifier: Programming Language :: Python :: 3
7
- Classifier: License :: OSI Approved :: MIT License
8
- Requires-Python: >=3.8
9
- Requires-Dist: pytest>=7.0
10
- Requires-Dist: cppcheck>=1.4.0