Skip to content
Snippets Groups Projects
Commit 01fa052f authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

Windows-proofing

parent ace191a4
No related branches found
No related tags found
No related merge requests found
# v2.7.5
* added extras to setup.py
* fixed infinite hang in `satella.files.split` on Windows
* made tests pass on Windows
* added `AggregateMetric`
# v2.7.4
......
__version__ = '2.7.5_a1'
__version__ = '2.7.5_a2'
import typing as tp
import re
import os
__all__ = ['read_re_sub_and_write', 'find_files', 'split']
SEPARATORS = {'\\', '/'}
......@@ -9,6 +8,10 @@ SEPARATORS.add(os.path.sep)
def _has_separator(path: str) -> bool:
# handle Windows case
if len(path) == 3:
if path.endswith(':/') or path.endswith(':\\'):
return False
return any(map(lambda x: x in path, SEPARATORS))
......
......@@ -7,8 +7,11 @@ from satella.files import read_re_sub_and_write, find_files, split
class TestFiles(unittest.TestCase):
def test_split(self):
self.assertEqual(split('c:/windows/system32/system32.exe'), ['c:', 'windows', 'system32',
'system32.exe'])
self.assertIn(split('c:/windows/system32/system32.exe'), [['c:', 'windows', 'system32',
'system32.exe'],
['c:/', 'windows', 'system32',
'system32.exe']
])
self.assertEqual(split('~/user/something/./else'), ['~', 'user', 'something', '.',
'else'])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment