diff options
| author | Jonathan Lange <jml@canonical.com> | 2012-07-08 14:21:01 +0100 |
|---|---|---|
| committer | Jonathan Lange <jml@canonical.com> | 2012-07-08 14:21:01 +0100 |
| commit | ee58bb55142b514dab62dc201c80056331f64405 (patch) | |
| tree | 1ce4e8a234713cb6a67acb420fabe6e042161ca4 /pyflakes/test/test_script.py | |
| parent | 5b3224fe27aa4157297277f3fe352a4d7b2d5af4 (diff) | |
| download | pyflakes-ee58bb55142b514dab62dc201c80056331f64405.tar.gz | |
Split out the bit that checks recursively.
Diffstat (limited to 'pyflakes/test/test_script.py')
| -rw-r--r-- | pyflakes/test/test_script.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pyflakes/test/test_script.py b/pyflakes/test/test_script.py index 80a6f16..af26fb9 100644 --- a/pyflakes/test/test_script.py +++ b/pyflakes/test/test_script.py @@ -12,6 +12,7 @@ from twisted.trial.unittest import TestCase from pyflakes.messages import UnusedImport from pyflakes.scripts.pyflakes import ( checkPath, + checkRecursive, iterSourceCode, Reporter, ) @@ -412,3 +413,26 @@ x = "\N{SNOWMAN}" sourcePath = self.makeTempFile(source) self.assertHasErrors( sourcePath, ["%s: problem decoding source\n" % (sourcePath,)]) + + + def test_checkRecursive(self): + """ + L{checkRecursive} descends into each directory, finding Python files + and reporting problems. + """ + tempdir = FilePath(self.mktemp()) + tempdir.createDirectory() + tempdir.child('foo').createDirectory() + file1 = tempdir.child('foo').child('bar.py') + file1.setContent("import baz\n") + file2 = tempdir.child('baz.py') + file2.setContent("import contraband") + log = [] + reporter = LoggingReporter(log) + warnings = checkRecursive([tempdir.path], reporter) + self.assertEqual(warnings, 2) + self.assertEqual( + sorted(log), + sorted([('flake', str(UnusedImport(file1.path, 1, 'baz'))), + ('flake', + str(UnusedImport(file2.path, 1, 'contraband')))])) |
