Add a test case which simply compiles all modules, useful for testing syntax
authorZac Medico <zmedico@gentoo.org>
Wed, 25 Nov 2009 22:32:26 +0000 (22:32 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 25 Nov 2009 22:32:26 +0000 (22:32 -0000)
compatibility with the current version of python. (trunk r14876)

svn path=/main/branches/2.1.7/; revision=14889

pym/portage/tests/lint/__init__.py [new file with mode: 0644]
pym/portage/tests/lint/__test__ [new file with mode: 0644]
pym/portage/tests/lint/test_compile_modules.py [new file with mode: 0644]

diff --git a/pym/portage/tests/lint/__init__.py b/pym/portage/tests/lint/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/pym/portage/tests/lint/__test__ b/pym/portage/tests/lint/__test__
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/pym/portage/tests/lint/test_compile_modules.py b/pym/portage/tests/lint/test_compile_modules.py
new file mode 100644 (file)
index 0000000..da039f4
--- /dev/null
@@ -0,0 +1,23 @@
+# Copyright 2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+from portage.const import PORTAGE_PYM_PATH
+from portage.tests import TestCase
+from portage import os
+from portage import _encodings
+from portage import _unicode_decode
+
+import py_compile
+
+class CompileModulesTestCase(TestCase):
+
+       def testCompileModules(self):
+               for parent, dirs, files in os.walk(PORTAGE_PYM_PATH):
+                       parent = _unicode_decode(parent,
+                               encoding=_encodings['fs'], errors='strict')
+                       for x in files:
+                               x = _unicode_decode(x,
+                                       encoding=_encodings['fs'], errors='strict')
+                               if x[-3:] == '.py':
+                                       py_compile.compile(os.path.join(parent, x), doraise=True)