mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Add example for new copydir_run_2to3().
This commit is contained in:
parent
fa1fcd107d
commit
bb93d17770
3 changed files with 29 additions and 2 deletions
|
@ -20,7 +20,7 @@ setup(
|
|||
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,
|
||||
}
|
||||
)
|
||||
|
|
19
Demo/distutils/test2to3/test/runtests.py
Normal file
19
Demo/distutils/test2to3/test/runtests.py
Normal file
|
@ -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()
|
8
Demo/distutils/test2to3/test/test_foo.py
Normal file
8
Demo/distutils/test2to3/test/test_foo.py
Normal file
|
@ -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)
|
Loading…
Add table
Add a link
Reference in a new issue