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

Method validate_cmd

Lib/test/test_tabnanny.py:296–314  ·  view source on GitHub ↗

Common function to assert the behaviour of command line interface.

(self, *args, stdout="", stderr="", partial=False, expect_failure=False)

Source from the content-addressed store, hash-verified

294 """Tests command line interface of `tabnanny`."""
295
296 def validate_cmd(self, *args, stdout="", stderr="", partial=False, expect_failure=False):
297 """Common function to assert the behaviour of command line interface."""
298 if expect_failure:
299 _, out, err = script_helper.assert_python_failure('-m', 'tabnanny', *args)
300 else:
301 _, out, err = script_helper.assert_python_ok('-m', 'tabnanny', *args)
302 # Note: The `splitlines()` will solve the problem of CRLF(\r) added
303 # by OS Windows.
304 out = os.fsdecode(out)
305 err = os.fsdecode(err)
306 if partial:
307 for std, output in ((stdout, out), (stderr, err)):
308 _output = output.splitlines()
309 for _std in std.splitlines():
310 with self.subTest(std=_std, output=_output):
311 self.assertIn(_std, _output)
312 else:
313 self.assertListEqual(out.splitlines(), stdout.splitlines())
314 self.assertListEqual(err.splitlines(), stderr.splitlines())
315
316 def test_with_errored_file(self):
317 """Should displays error when errored python file is given."""

Callers 6

test_command_usageMethod · 0.95
test_quiet_flagMethod · 0.95
test_verbose_modeMethod · 0.95

Calls 6

assert_python_failureMethod · 0.80
assert_python_okMethod · 0.80
assertInMethod · 0.80
assertListEqualMethod · 0.80
splitlinesMethod · 0.45
subTestMethod · 0.45

Tested by

no test coverage detected