[Python-checkins] r70786 - in python/branches/py3k/Demo/distutils/test2to3: setup.py test test/runtests.py test/test_foo.py

georg.brandl python-checkins at python.org
Tue Mar 31 02:33:15 CEST 2009


Author: georg.brandl
Date: Tue Mar 31 02:33:15 2009
New Revision: 70786

Log:
Add example for new copydir_run_2to3().

Added:
   python/branches/py3k/Demo/distutils/test2to3/test/
   python/branches/py3k/Demo/distutils/test2to3/test/runtests.py   (contents, props changed)
   python/branches/py3k/Demo/distutils/test2to3/test/test_foo.py   (contents, props changed)
Modified:
   python/branches/py3k/Demo/distutils/test2to3/   (props changed)
   python/branches/py3k/Demo/distutils/test2to3/setup.py

Modified: python/branches/py3k/Demo/distutils/test2to3/setup.py
==============================================================================
--- python/branches/py3k/Demo/distutils/test2to3/setup.py	(original)
+++ python/branches/py3k/Demo/distutils/test2to3/setup.py	Tue Mar 31 02:33:15 2009
@@ -20,7 +20,7 @@
     license = "PSF license",
     packages = ["test2to3"],
     scripts = ["maintest.py"],
-    cmdclass = {'build_py':build_py,
-                'build_scripts':build_scripts,
+    cmdclass = {'build_py': build_py,
+                'build_scripts': build_scripts,
                 }
 )

Added: python/branches/py3k/Demo/distutils/test2to3/test/runtests.py
==============================================================================
--- (empty file)
+++ python/branches/py3k/Demo/distutils/test2to3/test/runtests.py	Tue Mar 31 02:33:15 2009
@@ -0,0 +1,19 @@
+# Fictitious test runner for the project
+
+import sys, os
+
+if sys.version_info > (3,):
+    # copy test suite over to "build/lib" and convert it
+    from distutils.util import copydir_run_2to3
+    testroot = os.path.dirname(__file__)
+    newroot = os.path.join(testroot, '..', 'build/lib/test')
+    copydir_run_2to3(testroot, newroot)
+    # in the following imports, pick up the converted modules
+    sys.path[0] = newroot
+
+# run the tests here...
+
+from test_foo import FooTest
+
+import unittest
+unittest.main()

Added: python/branches/py3k/Demo/distutils/test2to3/test/test_foo.py
==============================================================================
--- (empty file)
+++ python/branches/py3k/Demo/distutils/test2to3/test/test_foo.py	Tue Mar 31 02:33:15 2009
@@ -0,0 +1,8 @@
+import sys
+import unittest
+
+class FooTest(unittest.TestCase):
+    def test_foo(self):
+        # use 2.6 syntax to demonstrate conversion
+        print 'In test_foo, using Python %s...' % (sys.version_info,)
+        self.assertTrue(False)


More information about the Python-checkins mailing list