@@ -4718,6 +4718,27 @@ def bar():
47184718 ]))
47194719 self .assertIn ('break in bar' , stdout )
47204720
4721+ def test_end_of_options_separator (self ):
4722+ # gh-148615: Test parsing when '--' separator is used
4723+ script = "import sys; print(f'ARGS: {sys.argv[1:]}')"
4724+ with open (os_helper .TESTFN , 'w' , encoding = 'utf-8' ) as f :
4725+ f .write (script )
4726+ stdout , _ = self ._run_pdb (['--' , os_helper .TESTFN , '-foo' ], 'c\n q' )
4727+ self .assertIn ("ARGS: ['-foo']" , stdout )
4728+ stdout , _ = self ._run_pdb (['-c' , 'continue' , '--' , os_helper .TESTFN , '-c' , 'foo' ], 'q' )
4729+ self .assertIn ("ARGS: ['-c', 'foo']" , stdout )
4730+ stdout , stderr = self ._run_pdb (['--' ], 'q' , expected_returncode = 2 )
4731+ self .assertIn ("missing script or module to run" , stderr )
4732+ stdout , stderr = self ._run_pdb (['-x' , '--' , os_helper .TESTFN ], 'q' , expected_returncode = 2 )
4733+ self .assertIn ("unrecognized arguments: -x" , stderr )
4734+ stdout , _ = self ._run_pdb ([os_helper .TESTFN , '--' , 'arg' ], 'c\n q' )
4735+ self .assertIn ("ARGS: ['--', 'arg']" , stdout )
4736+ with os_helper .temp_cwd ():
4737+ with open ('mymod.py' , 'w' , encoding = 'utf-8' ) as f :
4738+ f .write (script )
4739+ stdout , _ = self ._run_pdb (['-m' , 'mymod' , '--' , 'arg' ], 'c\n q' )
4740+ self .assertIn ("ARGS: ['--', 'arg']" , stdout )
4741+
47214742 @unittest .skipIf (SKIP_CORO_TESTS , "Coroutine tests are skipped" )
47224743 def test_async_break (self ):
47234744 script = """
0 commit comments