diff options
author | Ian Lee <IanLee1521@gmail.com> | 2014-12-13 13:34:29 -0800 |
---|---|---|
committer | Ian Lee <IanLee1521@gmail.com> | 2014-12-13 13:34:29 -0800 |
commit | 144a4d09927f421a5bb5968190c35fa8ae189d41 (patch) | |
tree | 9bfb7ff94ddad9d6d6f28068b8cc29b43e74b3f4 | |
parent | 499013556679f8c23de346a5f2ad48870edcb56c (diff) | |
parent | 4f5e7120a840a40e6184de06c2ec8b081196ccc1 (diff) | |
download | pep8-144a4d09927f421a5bb5968190c35fa8ae189d41.tar.gz |
Merge branch 'willkg:normalize_path_fix'
Pull request #343, Issues #339 / #343
-rw-r--r-- | CHANGES.txt | 2 | ||||
-rwxr-xr-x | pep8.py | 5 | ||||
-rw-r--r-- | testsuite/test_all.py | 3 | ||||
-rw-r--r-- | testsuite/test_util.py | 23 |
4 files changed, 31 insertions, 2 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 2fbab2d..a178e6c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -22,6 +22,8 @@ Bug fixes: * Report E266 instead of E265 when the block comment starts with multiple ``#``. (Issue #270) +* Strip whitespace from around paths during normalization. (Issue #339 / #343) + 1.5.7 (2014-05-29) ------------------ @@ -1156,10 +1156,13 @@ def normalize_paths(value, parent=os.curdir): Return a list of absolute paths. """ - if not value or isinstance(value, list): + if not value: + return [] + if isinstance(value, list): return value paths = [] for path in value.split(','): + path = path.strip() if '/' in path: path = os.path.abspath(os.path.join(parent, path)) paths.append(path.rstrip('/')) diff --git a/testsuite/test_all.py b/testsuite/test_all.py index 5160900..50e2cb9 100644 --- a/testsuite/test_all.py +++ b/testsuite/test_all.py @@ -46,12 +46,13 @@ class Pep8TestCase(unittest.TestCase): def suite(): - from testsuite import test_api, test_shell + from testsuite import test_api, test_shell, test_util suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(Pep8TestCase)) suite.addTest(unittest.makeSuite(test_api.APITestCase)) suite.addTest(unittest.makeSuite(test_shell.ShellTestCase)) + suite.addTest(unittest.makeSuite(test_util.UtilTestCase)) return suite diff --git a/testsuite/test_util.py b/testsuite/test_util.py new file mode 100644 index 0000000..658d057 --- /dev/null +++ b/testsuite/test_util.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import os +import unittest + +import pep8 + + +class UtilTestCase(unittest.TestCase): + def test_normalize_paths(self): + cwd = os.getcwd() + + self.assertEquals(pep8.normalize_paths(''), []) + self.assertEquals(pep8.normalize_paths([]), []) + self.assertEquals(pep8.normalize_paths(None), []) + self.assertEquals(pep8.normalize_paths(['foo']), ['foo']) + self.assertEquals(pep8.normalize_paths('foo'), ['foo']) + self.assertEquals(pep8.normalize_paths('foo,bar'), ['foo', 'bar']) + self.assertEquals(pep8.normalize_paths('foo, bar '), ['foo', 'bar']) + self.assertEquals(pep8.normalize_paths('/foo/bar,baz/../bat'), + ['/foo/bar', cwd + '/bat']) + self.assertEquals(pep8.normalize_paths(".pyc,\n build/*"), + ['.pyc', cwd + '/build/*']) |