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

Method test_basic

axlearn/cli/utils_test.py:61–78  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

59 self.skipTest(f"CLI {self.root_module} has not been installed -- skipping tests.")
60
61 def test_basic(self):
62 # Test that invoking an invalid command group or command exits with error.
63 with mock.patch("sys.stderr", new=StringIO()) as stderr:
64 with self.assertRaises(SystemExit) as e:
65 _parse([self.root_module, "unknown"])
66 self.assertEqual(e.exception.code, 2)
67 self.assertIn(
68 "invalid choice: 'unknown' (choose from 'child1', 'child2')", stderr.getvalue()
69 )
70
71 # Test that invoking CLI by itself prints the help message.
72 returncode, stdout, stderr = _run(_parse([self.root_module]))
73 self.assertRegex(stdout, r"usage: .*")
74 self.assertEqual(returncode, 0, msg=stderr)
75
76 # Test that invoking subcommand by itself injects --help.
77 args = _parse([self.root_module, "child1"])
78 self.assertEqual(args.command_type, CommandType.HELP)
79
80 def test_help(self):
81 # Test that passing --help exits without error.

Callers

nothing calls this directly

Calls 3

_parseFunction · 0.85
_runFunction · 0.70
patchMethod · 0.45

Tested by

no test coverage detected