Fix error trying to generate scripts warning when PATH not set

fixes #5558
This commit is contained in:
Oliver Jeeves 2018-07-02 13:14:28 +01:00 committed by Pradyun Gedam
parent c39a51003e
commit ca5cca3426
No known key found for this signature in database
GPG Key ID: DA17C4B29CB32E4B
3 changed files with 15 additions and 1 deletions

1
news/5558.bugfix Normal file
View File

@ -0,0 +1 @@
Fix error trying to generate scripts warning when PATH not set

View File

@ -163,7 +163,7 @@ def message_about_scripts_not_on_PATH(scripts):
# We don't want to warn for directories that are on PATH.
not_warn_dirs = [
os.path.normcase(i).rstrip(os.sep) for i in
os.environ["PATH"].split(os.pathsep)
os.environ.get("PATH", "").split(os.pathsep)
]
# If an executable sits with sys.executable, we don't warn for it.
# This covers the case of venv invocations without activating the venv.

View File

@ -470,3 +470,16 @@ class TestMessageAboutScriptsNotOnPATH(object):
scripts=[os.path.join('a', 'b', 'c')]
)
assert retval is None
def test_missing_PATH_env_treated_as_empty_PATH_env(self):
scripts = ['a/b/foo']
env = os.environ.copy()
del env['PATH']
with patch.dict('os.environ', env, clear=True):
retval_missing = wheel.message_about_scripts_not_on_PATH(scripts)
with patch.dict('os.environ', {'PATH': ''}):
retval_empty = wheel.message_about_scripts_not_on_PATH(scripts)
assert retval_missing == retval_empty