Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unit.utils.test_which on Windows #48096

Merged
merged 1 commit into from Jun 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions tests/unit/utils/test_which.py
Expand Up @@ -51,14 +51,14 @@ def test_existing_binary_in_windows(self):
True
]
# Let's patch os.environ to provide a custom PATH variable
with patch.dict(os.environ, {'PATH': '/bin',
with patch.dict(os.environ, {'PATH': os.sep + 'bin',
'PATHEXT': '.COM;.EXE;.BAT;.CMD'}):
# Let's also patch is_windows to return True
with patch('salt.utils.platform.is_windows', lambda: True):
with patch('os.path.isfile', lambda x: True):
self.assertEqual(
salt.utils.path.which('this-binary-exists-under-windows'),
os.path.join('/bin', 'this-binary-exists-under-windows.EXE')
os.path.join(os.sep + 'bin', 'this-binary-exists-under-windows.EXE')
)

def test_missing_binary_in_windows(self):
Expand All @@ -73,7 +73,7 @@ def test_missing_binary_in_windows(self):
False, False, False, False, False
]
# Let's patch os.environ to provide a custom PATH variable
with patch.dict(os.environ, {'PATH': '/bin'}):
with patch.dict(os.environ, {'PATH': os.sep + 'bin'}):
# Let's also patch is_widows to return True
with patch('salt.utils.platform.is_windows', lambda: True):
self.assertEqual(
Expand Down Expand Up @@ -101,13 +101,13 @@ def test_existing_binary_in_windows_pathext(self):
True
]
# Let's patch os.environ to provide a custom PATH variable
with patch.dict(os.environ, {'PATH': '/bin',
with patch.dict(os.environ, {'PATH': os.sep + 'bin',
'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;'
'.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY'}):
# Let's also patch is_windows to return True
with patch('salt.utils.platform.is_windows', lambda: True):
with patch('os.path.isfile', lambda x: True):
self.assertEqual(
salt.utils.path.which('this-binary-exists-under-windows'),
os.path.join('/bin', 'this-binary-exists-under-windows.CMD')
os.path.join(os.sep + 'bin', 'this-binary-exists-under-windows.CMD')
)