summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2013-12-31 21:36:26 +0100
committerMichael Vogt <mvo@debian.org>2014-01-05 20:04:13 +0100
commit830cced39fa293b17ab73d231fc5cc5e22e77c43 (patch)
treeffb0aada750241f8bdd57ca93cd0637ffc0f99d2 /tests
parent29d9d4270c7a7a1f40faed5a46443b33feb8cf9b (diff)
downloadpython-apt-830cced39fa293b17ab73d231fc5cc5e22e77c43.tar.gz
add pyflakes test
Diffstat (limited to 'tests')
-rw-r--r--tests/test_pyflakes.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/test_pyflakes.py b/tests/test_pyflakes.py
new file mode 100644
index 00000000..9c17a405
--- /dev/null
+++ b/tests/test_pyflakes.py
@@ -0,0 +1,41 @@
+#!/usr/bin/python3
+# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
+
+import os
+import subprocess
+import unittest
+
+
+class TestPyflakesClean(unittest.TestCase):
+
+ EXCLUDES = ["build", "tests/old"]
+ 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 = ["pyflakes"] + 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()