diff options
Diffstat (limited to '')
-rw-r--r-- | tests/test_pyflakes.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/test_pyflakes.py b/tests/test_pyflakes.py new file mode 100644 index 0000000..f26433a --- /dev/null +++ b/tests/test_pyflakes.py @@ -0,0 +1,43 @@ +#!/usr/bin/python3 + +import os +import subprocess +import unittest + +import testcommon + + +class TestPyflakesClean(testcommon.TestCase): + EXCLUDES = ["build", "tests/old", ".pybuild"] + TOPLEVEL = os.path.normpath( + os.path.join(os.path.dirname(os.path.abspath(__file__)), "..") + ) + + def is_excluded_path(self, path): + for exclude in self.EXCLUDES: + if path.startswith(os.path.join(self.TOPLEVEL, exclude)): + return True + return False + + def get_py_files(self, toplevel): + files = [] + for path, dirnames, filenames in os.walk(self.TOPLEVEL): + if self.is_excluded_path(path): + continue + for filename in filenames: + if os.path.splitext(filename)[1] == ".py": + files.append(os.path.join(path, filename)) + return files + + def test_pyflakes_clean(self): + cmd = ["pyflakes3"] + self.get_py_files(self.TOPLEVEL) + res = subprocess.call(cmd) + if res != 0: + self.fail("pyflakes failed with: %s" % res) + + +if __name__ == "__main__": + import logging + + logging.basicConfig(level=logging.DEBUG) + unittest.main() |