MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_skip_invalid_stdout

Method test_skip_invalid_stdout

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected