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

Method test_unknown_options

Lib/test/test_cmd_line.py:624–640  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

622
623 @support.cpython_only
624 def test_unknown_options(self):
625 rc, out, err = assert_python_failure('-E', '-z')
626 self.assertIn(b'Unknown option: -z', err)
627 self.assertEqual(err.splitlines().count(b'Unknown option: -z'), 1)
628 self.assertEqual(b'', out)
629 # Add "without='-E'" to prevent _assert_python to append -E
630 # to env_vars and change the output of stderr
631 rc, out, err = assert_python_failure('-z', without='-E')
632 self.assertIn(b'Unknown option: -z', err)
633 self.assertEqual(err.splitlines().count(b'Unknown option: -z'), 1)
634 self.assertEqual(b'', out)
635 rc, out, err = assert_python_failure('-a', '-z', without='-E')
636 self.assertIn(b'Unknown option: -a', err)
637 # only the first unknown option is reported
638 self.assertNotIn(b'Unknown option: -z', err)
639 self.assertEqual(err.splitlines().count(b'Unknown option: -a'), 1)
640 self.assertEqual(b'', out)
641
642 @unittest.skipIf(interpreter_requires_environment(),
643 'Cannot run -I tests when PYTHON env vars are required.')

Callers

nothing calls this directly

Calls 6

assert_python_failureFunction · 0.90
assertInMethod · 0.80
assertNotInMethod · 0.80
assertEqualMethod · 0.45
countMethod · 0.45
splitlinesMethod · 0.45

Tested by

no test coverage detected