aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'gentoolkit/pym/gentoolkit/test/test_syntax.py')
-rw-r--r--gentoolkit/pym/gentoolkit/test/test_syntax.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/gentoolkit/pym/gentoolkit/test/test_syntax.py b/gentoolkit/pym/gentoolkit/test/test_syntax.py
new file mode 100644
index 0000000..bb7dcb4
--- /dev/null
+++ b/gentoolkit/pym/gentoolkit/test/test_syntax.py
@@ -0,0 +1,33 @@
+import os
+import os.path as osp
+import unittest
+import py_compile
+
+"""Does a basic syntax check by compiling all modules. From Portage."""
+
+pym_dirs = os.walk(osp.dirname(osp.dirname(osp.dirname(__file__))))
+blacklist_dirs = frozenset(('.svn', 'test'))
+
+class TestForSyntaxErrors(unittest.TestCase):
+
+ def test_compileability(self):
+ compileables = []
+ for thisdir, subdirs, files in pym_dirs:
+ if os.path.basename(thisdir) in blacklist_dirs:
+ continue
+ compileables.extend([
+ osp.join(thisdir, f)
+ for f in files
+ if osp.splitext(f)[1] == '.py'
+ ])
+
+ for c in compileables:
+ py_compile.compile(c, doraise=True)
+
+
+def test_main():
+ test_support.run_unittest(TestGentoolkitHelpers2)
+
+
+if __name__ == '__main__':
+ test_main()