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

Function test_arguments_regression

addons/test/y2038_test.py:145–175  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

143
144
145def test_arguments_regression():
146 args_ok = ["-t=foo", "--template=foo",
147 "-q", "--quiet",
148 "--cli"]
149 # Arguments with expected SystemExit
150 args_exit = ["--non-exists", "--non-exists-param=42", "-h", "--help"]
151
152 from addons.y2038 import get_args_parser
153
154 # sys.argv contains all pytest arguments - so clear all existing arguments first and restore afterwards
155 sys_argv_old = sys.argv
156 sys.argv = [sys.argv[0]]
157
158 try:
159 for arg in args_exit:
160 sys.argv.append(arg)
161 with pytest.raises(SystemExit):
162 parser = get_args_parser()
163 parser.parse_args()
164 sys.argv.remove(arg)
165
166 for arg in args_ok:
167 sys.argv.append(arg)
168 try:
169 parser = get_args_parser()
170 parser.parse_args()
171 except SystemExit:
172 pytest.fail("Unexpected SystemExit with '%s'" % arg)
173 sys.argv.remove(arg)
174 finally:
175 sys.argv = sys_argv_old
176
177
178def test_parse_dump_config():

Callers

nothing calls this directly

Calls 2

get_args_parserFunction · 0.90
failMethod · 0.80

Tested by

no test coverage detected