@@ -1458,6 +1458,26 @@ def check_ignored(option):
14581458
14591459 # -c, -h, -m, -V and -? are tested elsewhere
14601460
1461+ def test_unknown_options (self ):
1462+ for option in ('-a' , '--long-option' ):
1463+ with self .subTest (option = option ):
1464+ proc = assert_python_failure (option )
1465+ errmsg = f'Unknown option: { option } '
1466+ self .assertStartsWith (proc .err .rstrip (), errmsg .encode ())
1467+
1468+ def test_missing_argument (self ):
1469+ def check_missing_arg (option ):
1470+ proc = assert_python_failure (option )
1471+ self .assertEqual (proc .rc , 2 )
1472+ errmsg = f"Argument expected for the { option } option"
1473+ self .assertStartsWith (proc .err .rstrip (), errmsg .encode ())
1474+
1475+ check_missing_arg ('-c' )
1476+ check_missing_arg ('-m' )
1477+ check_missing_arg ('-W' )
1478+ check_missing_arg ('-X' )
1479+ check_missing_arg ('--check-hash-based-pycs' )
1480+
14611481 def test_long_options (self ):
14621482 # Test long command line options
14631483
@@ -1469,8 +1489,17 @@ def test_long_options(self):
14691489 proc = assert_python_ok (opt , value , "-c" , code )
14701490 self .assertEqual (proc .out .rstrip (), value .encode ())
14711491
1472- # Other long options --help-all, --help-env and --help-xoptions
1473- # are tested elsewhere
1492+ # Other long options --help-all, --help-env, --help-xoptions
1493+ # and --version are tested elsewhere
1494+
1495+ def test_dash_option (self ):
1496+ # Test -- in the command line
1497+ code = (
1498+ 'import sys; '
1499+ 'print(sys.flags.isolated, sys.flags.optimize, sys.argv)'
1500+ )
1501+ proc = assert_python_ok ('-I' , '-c' , code , '--' , '-O' )
1502+ self .assertEqual (proc .out .rstrip (), b"1 0 ['-c', '--', '-O']" )
14741503
14751504
14761505@unittest .skipIf (interpreter_requires_environment (),
0 commit comments