MCPcopy Index your code
hub / github.com/python/cpython / test_skip_invalid_stdout

Method test_skip_invalid_stdout

Lib/test/test_argparse.py:64–80  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

62 parser.exit(status=0, message='foo')
63
64 def test_skip_invalid_stdout(self):
65 parser = argparse.ArgumentParser()
66 for func in (
67 parser.print_usage,
68 parser.print_help,
69 functools.partial(parser.parse_args, ['-h'])
70 ):
71 with (
72 self.subTest(func=func),
73 contextlib.redirect_stdout(None),
74 # argparse uses stderr as a fallback
75 StdIOBuffer() as mocked_stderr,
76 contextlib.redirect_stderr(mocked_stderr),
77 mock.patch('argparse._sys.exit'),
78 ):
79 func()
80 self.assertRegex(mocked_stderr.getvalue(), r'usage:')
81
82
83class TestArgumentParserPickleable(unittest.TestCase):

Callers

nothing calls this directly

Calls 6

StdIOBufferClass · 0.85
partialMethod · 0.80
assertRegexMethod · 0.80
funcFunction · 0.70
subTestMethod · 0.45
getvalueMethod · 0.45

Tested by

no test coverage detected