MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / test_cwe

Function test_cwe

test/cli/premium_test.py:170–184  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

168
169
170def test_cwe(tmpdir):
171 # Trac 14323 - addon warnings with cwe
172 test_file = os.path.join(tmpdir, 'test.c')
173 addon_file = os.path.join(tmpdir, 'premiumaddon.py')
174
175 with open(test_file, 'wt') as f:
176 f.write('void foo();\n')
177
178 args = [f"--addon={addon_file}", '--xml', test_file]
179
180 with open(addon_file, 'wt') as f:
181 f.write('print(\'{"addon":"a","column":1,"errorId":"id","extra":"","file":"test.c","cwe":123,"linenr":1,"message":"bug","severity":"error"}\')')
182
183 _, _, stderr = cppcheck(args)
184 assert '<error id="a-id" severity="error" msg="bug" verbose="bug" cwe="123" ' in stderr
185
186
187def test_hash(tmpdir):

Callers

nothing calls this directly

Calls 3

cppcheckFunction · 0.90
joinMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected