Skip to content

Commit 0ee9341

Browse files
committed
Patch abspath for linux testing ensure consistent paths on Windows
1 parent d86aa52 commit 0ee9341

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/os_linux_generic.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
import unittest
2020
import sys
21+
import os
2122
from mock import patch
2223
from mbed_lstools.linux import MbedLsToolsLinuxGeneric
2324

24-
2525
class LinuxPortTestCase(unittest.TestCase):
2626
''' Basic test cases checking trivial asserts
2727
'''
@@ -86,6 +86,7 @@ def find_candidates_with_patch(self, mount_list, link_dict, listdir_dict):
8686
with patch('mbed_lstools.linux.MbedLsToolsLinuxGeneric._run_cli_process') as _cliproc,\
8787
patch('os.readlink') as _readlink,\
8888
patch('os.listdir') as _listdir,\
89+
patch('mbed_lstools.linux.abspath') as _abspath,\
8990
patch('mbed_lstools.linux.isdir') as _isdir:
9091
_isdir.return_value = True
9192
_cliproc.return_value = (b'\n'.join(mount_list), None, 0)
@@ -99,6 +100,12 @@ def do_listdir(dir):
99100
dir = dir.replace('\\', '/')
100101
return listdir_dict[dir]
101102
_listdir.side_effect = do_listdir
103+
def do_abspath(dir):
104+
_, path = os.path.splitdrive(
105+
os.path.normpath(os.path.join(os.getcwd(), dir)))
106+
path = path.replace('\\', '/')
107+
return path
108+
_abspath.side_effect = do_abspath
102109
ret_val = self.linux_generic.find_candidates()
103110
_cliproc.assert_called_once_with('mount')
104111
return ret_val

0 commit comments

Comments
 (0)