@@ -85,6 +85,22 @@ def test_normexe_does_not_exist():
8585 assert excinfo .value .args == ('Executable `i-dont-exist-lol` not found' ,)
8686
8787
88+ def test_normexe_does_not_exist_sep ():
89+ with pytest .raises (OSError ) as excinfo :
90+ parse_shebang .normexe ('./i-dont-exist-lol' )
91+ assert excinfo .value .args == ('Executable `./i-dont-exist-lol` not found' ,)
92+
93+
94+ def test_normexe_is_a_directory (tmpdir ):
95+ with tmpdir .as_cwd ():
96+ tmpdir .join ('exe' ).ensure_dir ()
97+ exe = os .path .join ('.' , 'exe' )
98+ with pytest .raises (OSError ) as excinfo :
99+ parse_shebang .normexe (exe )
100+ msg , = excinfo .value .args
101+ assert msg == 'Executable `{}` is a directory' .format (exe )
102+
103+
88104def test_normexe_already_full_path ():
89105 assert parse_shebang .normexe (sys .executable ) == sys .executable
90106
@@ -107,14 +123,14 @@ def test_normalize_cmd_PATH():
107123
108124
109125def test_normalize_cmd_shebang (in_tmpdir ):
110- python = distutils .spawn .find_executable ('python' )
111- path = write_executable (python . replace ( os . sep , '/' ) )
126+ python = distutils .spawn .find_executable ('python' ). replace ( os . sep , '/' )
127+ path = write_executable (python )
112128 assert parse_shebang .normalize_cmd ((path ,)) == (python , path )
113129
114130
115131def test_normalize_cmd_PATH_shebang_full_path (in_tmpdir ):
116- python = distutils .spawn .find_executable ('python' )
117- path = write_executable (python . replace ( os . sep , '/' ) )
132+ python = distutils .spawn .find_executable ('python' ). replace ( os . sep , '/' )
133+ path = write_executable (python )
118134 with bin_on_path ():
119135 ret = parse_shebang .normalize_cmd (('run' ,))
120136 assert ret == (python , os .path .abspath (path ))
0 commit comments