diff options
author | Simon Sawicki <contact@grub4k.xyz> | 2024-10-13 04:10:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-13 04:10:12 +0200 |
commit | 85b87c991af25dcb35630fa94580fd418e78ee33 (patch) | |
tree | bc2eb543c4d430305f2198333acfc6abed8f2bdd /test | |
parent | 16eb28026a2ddf5608d0a628ef15949b8d3805a9 (diff) |
[utils] `sanitize_path`: Reimplement function (#11198)
Authored by: Grub4K
Diffstat (limited to 'test')
-rw-r--r-- | test/test_utils.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/test/test_utils.py b/test/test_utils.py index 4f5fa1e10..d4b846f56 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -221,9 +221,10 @@ class TestUtil(unittest.TestCase): self.assertEqual(sanitize_filename('N0Y__7-UOdI', is_id=True), 'N0Y__7-UOdI') def test_sanitize_path(self): - if sys.platform != 'win32': - return + with unittest.mock.patch('sys.platform', 'win32'): + self._test_sanitize_path() + def _test_sanitize_path(self): self.assertEqual(sanitize_path('abc'), 'abc') self.assertEqual(sanitize_path('abc/def'), 'abc\\def') self.assertEqual(sanitize_path('abc\\def'), 'abc\\def') @@ -256,6 +257,11 @@ class TestUtil(unittest.TestCase): self.assertEqual(sanitize_path('./abc'), 'abc') self.assertEqual(sanitize_path('./../abc'), '..\\abc') + self.assertEqual(sanitize_path('\\abc'), '\\abc') + self.assertEqual(sanitize_path('C:abc'), 'C:abc') + self.assertEqual(sanitize_path('C:abc\\..\\'), 'C:..') + self.assertEqual(sanitize_path('C:\\abc:%(title)s.%(ext)s'), 'C:\\abc#%(title)s.%(ext)s') + def test_sanitize_url(self): self.assertEqual(sanitize_url('//foo.bar'), 'http://foo.bar') self.assertEqual(sanitize_url('httpss://foo.bar'), 'https://foo.bar') |