From f450b525cccb3470cb98ee6f39cbe12e6db6bb1c Mon Sep 17 00:00:00 2001 From: ergoithz Date: Sat, 9 Sep 2017 21:37:35 +0200 Subject: [PATCH] fix path length checks on windows --- README.rst | 2 +- browsepy/__meta__.py | 2 +- browsepy/compat.py | 2 +- browsepy/tests/test_compat.py | 4 ++-- browsepy/tests/test_file.py | 5 ++++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index 0778a69..b077dac 100644 --- a/README.rst +++ b/README.rst @@ -23,7 +23,7 @@ browsepy .. image:: http://img.shields.io/pypi/v/browsepy.svg?style=flat-square :target: https://pypi.python.org/pypi/browsepy/ - :alt: Version: 0.5.5 + :alt: Version: 0.5.6 .. image:: https://img.shields.io/badge/python-2.7%2B%2C%203.3%2B-FFC100.svg?style=flat-square :target: https://pypi.python.org/pypi/browsepy/ diff --git a/browsepy/__meta__.py b/browsepy/__meta__.py index dbdbd26..0ca7f53 100644 --- a/browsepy/__meta__.py +++ b/browsepy/__meta__.py @@ -3,7 +3,7 @@ app = 'browsepy' description = 'Simple web file browser' -version = '0.5.5' +version = '0.5.6' license = 'MIT' author_name = 'Felipe A. Hernandez' author_mail = 'ergoithz@gmail.com' diff --git a/browsepy/compat.py b/browsepy/compat.py index d2ae2d4..913588b 100644 --- a/browsepy/compat.py +++ b/browsepy/compat.py @@ -250,7 +250,7 @@ def pathconf(path, if pathconf_fnc and pathconf_names: return {key: pathconf_fnc(path, key) for key in pathconf_names} if os_name == 'nt': - maxpath = 247 if isdir_fnc(path) else 259 # 260 minus + maxpath = 246 if isdir_fnc(path) else 259 # 260 minus else: maxpath = 255 # conservative sane default return { diff --git a/browsepy/tests/test_compat.py b/browsepy/tests/test_compat.py index 11856bb..31969ef 100644 --- a/browsepy/tests/test_compat.py +++ b/browsepy/tests/test_compat.py @@ -119,8 +119,8 @@ def test_pathconf(self): isdir_fnc=lambda x: True ) pcfg = self.module.pathconf('c:\\a', **kwargs) - self.assertEqual(pcfg['PC_PATH_MAX'], 247) - self.assertEqual(pcfg['PC_NAME_MAX'], 243) + self.assertEqual(pcfg['PC_PATH_MAX'], 246) + self.assertEqual(pcfg['PC_NAME_MAX'], 242) def test_getcwd(self): self.assertIsInstance(self.module.getcwd(), self.module.unicode) diff --git a/browsepy/tests/test_file.py b/browsepy/tests/test_file.py index 2ddc6b6..1032082 100644 --- a/browsepy/tests/test_file.py +++ b/browsepy/tests/test_file.py @@ -226,7 +226,10 @@ def test_fmt_size(self): def test_secure_filename(self): self.assertEqual(self.module.secure_filename('/path'), 'path') self.assertEqual(self.module.secure_filename('..'), '') - self.assertEqual(self.module.secure_filename('::'), '') + self.assertEqual( + self.module.secure_filename('::'), + '__' if os.name == 'nt' else '' + ) self.assertEqual(self.module.secure_filename('\0'), '_') self.assertEqual(self.module.secure_filename('/'), '') self.assertEqual(self.module.secure_filename('C:\\'), '')