@@ -54,10 +54,14 @@ def test_check_long_paths(fake_config):
5454 assert firstrun .check_long_paths (fake_config ) in (True , False )
5555
5656
57- def test_check_py_on_path (fake_config , monkeypatch ):
57+ def test_check_py_on_path (fake_config , monkeypatch , tmp_path ):
5858 monkeypatch .setattr (firstrun , "_package_name" , fake_package_name )
59+ mp = monkeypatch .setitem (os .environ , "PATH" , f";{ tmp_path } ;" )
5960 assert firstrun .check_py_on_path (fake_config ) in (True , False )
6061
62+ mp = monkeypatch .setitem (os .environ , "PATH" , "" )
63+ assert firstrun .check_py_on_path (fake_config ) == True
64+
6165 monkeypatch .setattr (firstrun , "_package_name" , fake_package_name_error )
6266 assert firstrun .check_py_on_path (fake_config ) == "skip"
6367
@@ -66,13 +70,17 @@ def test_check_py_on_path(fake_config, monkeypatch):
6670
6771
6872def test_check_global_dir (fake_config , monkeypatch , tmp_path ):
73+ fake_config .global_dir = None
74+ assert firstrun .check_global_dir (fake_config ) == "skip"
75+
6976 fake_config .global_dir = str (tmp_path )
7077 assert firstrun .check_global_dir (fake_config ) == False
7178
7279 monkeypatch .setattr (firstrun , "_check_global_dir_registry" , lambda * a : "called" )
7380 assert firstrun .check_global_dir (fake_config ) == "called"
7481
75- monkeypatch .setitem (os .environ , "PATH" , f"{ os .environ ['PATH' ]} ;{ tmp_path } " )
82+ # Some empty elements, as well as our "real" one
83+ monkeypatch .setitem (os .environ , "PATH" , f";;{ os .environ ['PATH' ]} ;{ tmp_path } " )
7684 assert firstrun .check_global_dir (fake_config ) == True
7785
7886
0 commit comments