summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZachary Ware <zachary.ware@gmail.com>2014-10-29 17:28:13 (GMT)
committerZachary Ware <zachary.ware@gmail.com>2014-10-29 17:28:13 (GMT)
commit0f26a3a8c9fa9e813c43ea414ea6df575b1ee4c4 (patch)
treea12798c61484c6060207142d54054e998dac98cb
parent55e614a2a8cc5b7a5af5795f87349ce3bf98fe84 (diff)
parent2acbae80165390a5be3bb12351147b8026787e13 (diff)
downloadcpython-0f26a3a8c9fa9e813c43ea414ea6df575b1ee4c4.zip
cpython-0f26a3a8c9fa9e813c43ea414ea6df575b1ee4c4.tar.gz
cpython-0f26a3a8c9fa9e813c43ea414ea6df575b1ee4c4.tar.bz2
Closes #22173: Merge with 3.4
-rw-r--r--Lib/lib2to3/main.py2
-rw-r--r--Lib/lib2to3/tests/__init__.py21
-rw-r--r--Lib/lib2to3/tests/__main__.py4
-rwxr-xr-xLib/lib2to3/tests/pytree_idempotency.py2
-rw-r--r--Lib/lib2to3/tests/test_all_fixers.py5
-rw-r--r--Lib/test/test_lib2to3.py21
-rw-r--r--Misc/NEWS2
7 files changed, 19 insertions, 38 deletions
diff --git a/Lib/lib2to3/main.py b/Lib/lib2to3/main.py
index 93bae90..1a1df01 100644
--- a/Lib/lib2to3/main.py
+++ b/Lib/lib2to3/main.py
@@ -2,7 +2,7 @@
Main program for 2to3.
"""
-from __future__ import with_statement
+from __future__ import with_statement, print_function
import sys
import os
diff --git a/Lib/lib2to3/tests/__init__.py b/Lib/lib2to3/tests/__init__.py
index cfaea0d..c5166fc 100644
--- a/Lib/lib2to3/tests/__init__.py
+++ b/Lib/lib2to3/tests/__init__.py
@@ -1,24 +1,9 @@
-"""Make tests/ into a package. This allows us to "import tests" and
-have tests.all_tests be a TestSuite representing all test cases
-from all test_*.py files in tests/."""
# Author: Collin Winter
import os
-import os.path
import unittest
-import types
-from . import support
+from test.support import load_package_tests
-all_tests = unittest.TestSuite()
-
-tests_dir = os.path.join(os.path.dirname(__file__), '..', 'tests')
-tests = [t[0:-3] for t in os.listdir(tests_dir)
- if t.startswith('test_') and t.endswith('.py')]
-
-loader = unittest.TestLoader()
-
-for t in tests:
- __import__("",globals(),locals(),[t],level=1)
- mod = globals()[t]
- all_tests.addTests(loader.loadTestsFromModule(mod))
+def load_tests(*args):
+ return load_package_tests(os.path.dirname(__file__), *args)
diff --git a/Lib/lib2to3/tests/__main__.py b/Lib/lib2to3/tests/__main__.py
new file mode 100644
index 0000000..40a23a2
--- /dev/null
+++ b/Lib/lib2to3/tests/__main__.py
@@ -0,0 +1,4 @@
+from . import load_tests
+import unittest
+
+unittest.main()
diff --git a/Lib/lib2to3/tests/pytree_idempotency.py b/Lib/lib2to3/tests/pytree_idempotency.py
index 731c403..c6359bf 100755
--- a/Lib/lib2to3/tests/pytree_idempotency.py
+++ b/Lib/lib2to3/tests/pytree_idempotency.py
@@ -4,6 +4,8 @@
"""Main program for testing the infrastructure."""
+from __future__ import print_function
+
__author__ = "Guido van Rossum <guido@python.org>"
# Support imports (need to be imported first)
diff --git a/Lib/lib2to3/tests/test_all_fixers.py b/Lib/lib2to3/tests/test_all_fixers.py
index f64b3d9..15079fe 100644
--- a/Lib/lib2to3/tests/test_all_fixers.py
+++ b/Lib/lib2to3/tests/test_all_fixers.py
@@ -7,12 +7,14 @@ running time.
# Python imports
import unittest
+import test.support
# Local imports
from lib2to3 import refactor
from . import support
+@test.support.requires_resource('cpu')
class Test_all(support.TestCase):
def setUp(self):
@@ -21,3 +23,6 @@ class Test_all(support.TestCase):
def test_all_project_files(self):
for filepath in support.all_project_files():
self.refactor.refactor_file(filepath)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/Lib/test/test_lib2to3.py b/Lib/test/test_lib2to3.py
index df4c37b..5eaa516 100644
--- a/Lib/test/test_lib2to3.py
+++ b/Lib/test/test_lib2to3.py
@@ -1,22 +1,5 @@
-# Skipping test_parser and test_all_fixers
-# because of running
-from lib2to3.tests import (test_fixers, test_pytree, test_util, test_refactor,
- test_parser,
- test_main as test_main_)
+from lib2to3.tests import load_tests
import unittest
-from test.support import run_unittest
-
-def suite():
- tests = unittest.TestSuite()
- loader = unittest.TestLoader()
- for m in (test_fixers, test_pytree, test_util, test_refactor, test_parser,
- test_main_):
- tests.addTests(loader.loadTestsFromModule(m))
- return tests
-
-def test_main():
- run_unittest(suite())
-
if __name__ == '__main__':
- test_main()
+ unittest.main()
diff --git a/Misc/NEWS b/Misc/NEWS
index b27e936..a6c563e 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -1235,6 +1235,8 @@ Documentation
Tests
-----
+- Issue #22173: Update lib2to3 tests to use unittest test discovery.
+
- Issue #20746: Fix test_pdb to run in refleak mode (-R). Patch by Xavier
de Gaye.