Skip to content

Commit 07babc1

Browse files
committed
Fixing platform detection tests on linux
1 parent baebaa5 commit 07babc1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

test/platform_detection.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import unittest
2020
import os
2121
import copy
22-
import pprint
2322
from mock import patch, mock_open, DEFAULT
2423

2524
from mbed_lstools.lstools_base import MbedLsToolsBase
@@ -38,6 +37,13 @@ def find_candidates(self):
3837
basestring = str
3938

4039

40+
def get_case_insensitive_path(path, file_name):
41+
for entry in os.listdir(path):
42+
if entry.lower() == file_name.lower():
43+
return os.path.join(path, entry)
44+
45+
raise Exception('No matching file for %s found in $s' % (file_name, path))
46+
4147

4248
class PlatformDetectionTestCase(unittest.TestCase):
4349
""" Basic test cases checking trivial asserts
@@ -72,9 +78,8 @@ def run_test(self, test_data_case, candidate_data, expected_data):
7278

7379
def do_open(path, mode='r'):
7480
file_name = os.path.basename(path)
75-
test_data_file_path = os.path.join(test_data_case_path, file_name)
7681
try:
77-
with open(test_data_file_path, 'r') as test_data_file:
82+
with open(get_case_insensitive_path(test_data_case_path, file_name), 'r') as test_data_file:
7883
test_data_file_data = test_data_file.read()
7984
except OSError:
8085
raise OSError("(mocked open) No such file or directory: '%s'" % (path))

0 commit comments

Comments
 (0)