mirror of
https://github.com/derrod/legendary.git
synced 2026-03-03 10:22:06 +00:00
Merge cc641e77c7 into 42af7b5db7
This commit is contained in:
commit
507ede3d5a
14
legendary/lfs/tests/test_wine_helpers.py
Normal file
14
legendary/lfs/tests/test_wine_helpers.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import unittest
|
||||
import os
|
||||
from unittest.mock import patch
|
||||
from legendary.lfs.wine_helpers import case_insensitive_file_search
|
||||
|
||||
class TestWineHelpers(unittest.TestCase):
|
||||
@patch('os.path.exists')
|
||||
def test_case_insensitive_file_search_nonexistent_dir(self, mock_exists):
|
||||
mock_exists.return_value = False
|
||||
result = case_insensitive_file_search('/nonexistent/path/to/file.txt')
|
||||
self.assertIsNone(result)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
@ -25,6 +25,9 @@ def case_insensitive_file_search(path: str) -> str:
|
|||
Similar to case_insensitive_path_search: Finds a file case-insensitively
|
||||
Note that this *does* work on Windows, although it's rather pointless
|
||||
"""
|
||||
if not os.path.exists(os.path.dirname(path)):
|
||||
return None
|
||||
|
||||
path_parts = os.path.normpath(path).split(os.sep)
|
||||
# If path_parts[0] is empty, we're on Unix and thus start searching at /
|
||||
if not path_parts[0]:
|
||||
|
|
|
|||
Loading…
Reference in a new issue