[Python-checkins] cpython (2.7): Issue #12618: create unit tests for the py_compile module
meador.inge
python-checkins at python.org
Sat Nov 26 06:45:30 CET 2011
http://hg.python.org/cpython/rev/bcc7bf3963cc
changeset: 73753:bcc7bf3963cc
branch: 2.7
parent: 73750:6783aa5c15ae
user: Meador Inge <meadori at gmail.com>
date: Fri Nov 25 23:28:18 2011 -0600
summary:
Issue #12618: create unit tests for the py_compile module
files:
Lib/test/test_py_compile.py | 43 +++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_py_compile.py b/Lib/test/test_py_compile.py
new file mode 100644
--- /dev/null
+++ b/Lib/test/test_py_compile.py
@@ -0,0 +1,43 @@
+import imp
+import os
+import py_compile
+import shutil
+import tempfile
+import unittest
+
+from test import test_support
+
+class PyCompileTests(unittest.TestCase):
+
+ def setUp(self):
+ self.directory = tempfile.mkdtemp()
+ self.source_path = os.path.join(self.directory, '_test.py')
+ self.pyc_path = self.source_path + 'c'
+ with open(self.source_path, 'w') as file:
+ file.write('x = 123\n')
+
+ def tearDown(self):
+ shutil.rmtree(self.directory)
+
+ def test_absolute_path(self):
+ py_compile.compile(self.source_path, self.pyc_path)
+ self.assertTrue(os.path.exists(self.pyc_path))
+
+ def test_cwd(self):
+ cwd = os.getcwd()
+ os.chdir(self.directory)
+ py_compile.compile(os.path.basename(self.source_path),
+ os.path.basename(self.pyc_path))
+ os.chdir(cwd)
+ self.assertTrue(os.path.exists(self.pyc_path))
+
+ def test_relative_path(self):
+ py_compile.compile(os.path.relpath(self.source_path),
+ os.path.relpath(self.pyc_path))
+ self.assertTrue(os.path.exists(self.pyc_path))
+
+def test_main():
+ test_support.run_unittest(PyCompileTests)
+
+if __name__ == "__main__":
+ test_main()
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list