@@ -2820,8 +2820,7 @@ def test_module_without_a_main(self):
2820
2820
stdout , stderr = self ._run_pdb (
2821
2821
['-m' , module_name ], "" , expected_returncode = 1
2822
2822
)
2823
- self .assertIn ("ImportError: No module named t_main.__main__" ,
2824
- stdout .splitlines ())
2823
+ self .assertIn ("ImportError: No module named t_main.__main__;" , stdout )
2825
2824
2826
2825
def test_package_without_a_main (self ):
2827
2826
pkg_name = 't_pkg'
@@ -2839,6 +2838,22 @@ def test_package_without_a_main(self):
2839
2838
"'t_pkg.t_main' is a package and cannot be directly executed" ,
2840
2839
stdout )
2841
2840
2841
+ def test_nonexistent_module (self ):
2842
+ assert not os .path .exists (os_helper .TESTFN )
2843
+ stdout , stderr = self ._run_pdb (["-m" , os_helper .TESTFN ], "" , expected_returncode = 1 )
2844
+ self .assertIn (f"ImportError: No module named { os_helper .TESTFN } " , stdout )
2845
+
2846
+ def test_dir_as_script (self ):
2847
+ with os_helper .temp_dir () as temp_dir :
2848
+ stdout , stderr = self ._run_pdb ([temp_dir ], "" , expected_returncode = 1 )
2849
+ self .assertIn (f"Error: { temp_dir } is a directory" , stdout )
2850
+
2851
+ def test_invalid_cmd_line_options (self ):
2852
+ stdout , stderr = self ._run_pdb (["-c" ], "" , expected_returncode = 2 )
2853
+ self .assertIn (f"pdb: error: argument -c/--command: expected one argument" , stdout .split ('\n ' )[1 ])
2854
+ stdout , stderr = self ._run_pdb (["--spam" , "-m" , "pdb" ], "" , expected_returncode = 2 )
2855
+ self .assertIn (f"pdb: error: unrecognized arguments: --spam" , stdout .split ('\n ' )[1 ])
2856
+
2842
2857
def test_blocks_at_first_code_line (self ):
2843
2858
script = """
2844
2859
#This is a comment, on line 2
0 commit comments