summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorWill Kahn-Greene <willkg@bluesock.org>2014-11-06 20:23:46 -0500
committerWill Kahn-Greene <willkg@bluesock.org>2014-11-06 20:23:46 -0500
commit78d959d7ef3f9b4182905a30ec4a2e2c93381fe9 (patch)
tree4f3c41c9d7c29d0b8ff0b1b3f1a8bd95261662ec /testsuite
parent4c5bf00cb613be617c7f48d3b2b82a1c7b895ac1 (diff)
downloadpep8-78d959d7ef3f9b4182905a30ec4a2e2c93381fe9.tar.gz
Fix normalize_paths to allow whitespace
This fixes normalize_paths so that it strips whitespace before and after paths before working on them. This allows you to do specify excludes with multiple lines in the config file. This also tweaks normalize_paths so that the behavior matches the docstring. This also adds tests. Fixes #339
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/test_all.py3
-rw-r--r--testsuite/test_util.py20
2 files changed, 22 insertions, 1 deletions
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..84b736a
--- /dev/null
+++ b/testsuite/test_util.py
@@ -0,0 +1,20 @@
+#!/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(['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,baz/../bat'),
+ ['/foo/bar', cwd + '/bat'])
+ self.assertEquals(pep8.normalize_paths(".pyc,\n build/*"),
+ ['.pyc', cwd + '/build/*'])