Use os.sep for paths

This commit is contained in:
twangboy 2018-06-13 12:04:37 -06:00
parent 9e1d0040e4
commit d26fc56f13
No known key found for this signature in database
GPG Key ID: 93FF3BDEB278C9EB

View File

@ -51,14 +51,14 @@ class TestWhich(TestCase):
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):
@ -73,7 +73,7 @@ class TestWhich(TestCase):
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(
@ -101,7 +101,7 @@ class TestWhich(TestCase):
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
@ -109,5 +109,5 @@ class TestWhich(TestCase):
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')
)