MCPcopy Create free account
hub / github.com/apple/axlearn / test_invoke_default

Method test_invoke_default

axlearn/cli/utils_test.py:246–288  ·  view source on GitHub ↗
(self, flags: list[str])

Source from the content-addressed store, hash-verified

244 (["--root_default", "override"],),
245 )
246 def test_invoke_default(self, flags: list[str]):
247 # Test invoking with a flag for which a default already exists.
248 args = _parse(
249 [
250 self.root_module,
251 "child1",
252 "grandchild1",
253 "command1",
254 "--required=test1",
255 ]
256 + flags
257 )
258 self.assertEqual(
259 args.argv,
260 [self.root_module, "--required=test1"] + flags + ["--undefok=root,root_default,child1"],
261 )
262 returncode, stdout, _ = _run(args)
263 self.assertEqual(returncode, 0)
264 self.assertEqual(stdout, "required: test1, optional: None, root_default: override")
265
266 # If the flags appear after "--", they are ignored, so the default flags should be kept.
267 args = _parse(
268 [
269 self.root_module,
270 "child1",
271 "grandchild1",
272 "command1",
273 "--required=test1",
274 "--",
275 ]
276 + flags
277 )
278 self.assertEqual(
279 args.argv,
280 [
281 self.root_module,
282 "--required=test1",
283 "--undefok=root,root_default,child1",
284 "--root_default=some_value", # Keep the default value.
285 "--",
286 ]
287 + flags, # Overrides come after "--".
288 )
289
290 def test_filter_argv(self):
291 # Test invoking a command which specifies a flag filter.

Callers

nothing calls this directly

Calls 2

_parseFunction · 0.85
_runFunction · 0.70

Tested by

no test coverage detected