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

Method test_help

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

Source from the content-addressed store, hash-verified

78 self.assertEqual(args.command_type, CommandType.HELP)
79
80 def test_help(self):
81 # Test that passing --help exits without error.
82 with mock.patch("sys.stdout", new=StringIO()) as stdout:
83 with self.assertRaises(SystemExit) as e:
84 _parse([self.root_module, "child1", "--help"])
85 self.assertEqual(e.exception.code, 0)
86
87 helpstring = stdout.getvalue().replace("\n", " ")
88 self.assertRegex(
89 helpstring, r"usage: .* child1 \[-h\] \[--helpfull\] \[--child1\] +{grandchild1}"
90 )
91
92 # Test that passing --help exits without error.
93 with mock.patch("sys.stdout", new=StringIO()) as stdout:
94 with self.assertRaises(SystemExit) as e:
95 _parse([self.root_module, "child1", "grandchild1", "--help"])
96 self.assertEqual(e.exception.code, 0)
97
98 helpstring = stdout.getvalue().replace("\n", " ")
99 self.assertRegex(
100 helpstring,
101 r"usage: .* child1 grandchild1 \[-h\] \[--helpfull\] +{command1,command2}",
102 )
103
104 def test_invoke_basic(self):
105 # Test invoking a command.

Callers

nothing calls this directly

Calls 3

_parseFunction · 0.85
replaceMethod · 0.80
patchMethod · 0.45

Tested by

no test coverage detected