]> granicus.if.org Git - python/commitdiff
#17303: test_future* now work with unittest test discovery. Patch by Zachary Ware.
authorEzio Melotti <ezio.melotti@gmail.com>
Wed, 27 Feb 2013 08:00:03 +0000 (10:00 +0200)
committerEzio Melotti <ezio.melotti@gmail.com>
Wed, 27 Feb 2013 08:00:03 +0000 (10:00 +0200)
Lib/test/test_future.py
Lib/test/test_future3.py
Lib/test/test_future4.py
Lib/test/test_future5.py
Misc/NEWS

index 3a25eb156508029adeec8a5c98cc8ea55f7c3a9f..a0c156f5f7baa6d17b5337f78f5c24a8da3a9837 100644 (file)
@@ -13,18 +13,18 @@ def get_error_location(msg):
 class FutureTest(unittest.TestCase):
 
     def test_future1(self):
-        support.unload('future_test1')
-        from test import future_test1
-        self.assertEqual(future_test1.result, 6)
+        with support.CleanImport('future_test1'):
+            from test import future_test1
+            self.assertEqual(future_test1.result, 6)
 
     def test_future2(self):
-        support.unload('future_test2')
-        from test import future_test2
-        self.assertEqual(future_test2.result, 6)
+        with support.CleanImport('future_test2'):
+            from test import future_test2
+            self.assertEqual(future_test2.result, 6)
 
     def test_future3(self):
-        support.unload('test_future3')
-        from test import test_future3
+        with support.CleanImport('test_future3'):
+            from test import test_future3
 
     def test_badfuture3(self):
         try:
@@ -103,8 +103,8 @@ class FutureTest(unittest.TestCase):
             self.fail("syntax error didn't occur")
 
     def test_multiple_features(self):
-        support.unload("test.test_future5")
-        from test import test_future5
+        with support.CleanImport("test.test_future5"):
+            from test import test_future5
 
     def test_unicode_literals_exec(self):
         scope = {}
@@ -112,8 +112,6 @@ class FutureTest(unittest.TestCase):
         self.assertIsInstance(scope["x"], str)
 
 
-def test_main():
-    support.run_unittest(FutureTest)
 
 if __name__ == "__main__":
-    test_main()
+    unittest.main()
index b1552a5e8e0146c89e0f76277df3020379212cf3..09f1c78fa3425e7b78e5e3d9035fa4a25abbd067 100644 (file)
@@ -2,7 +2,6 @@ from __future__ import nested_scopes
 from __future__ import division
 
 import unittest
-from test import support
 
 x = 2
 def nester():
@@ -23,8 +22,5 @@ class TestFuture(unittest.TestCase):
     def test_nested_scopes(self):
         self.assertEqual(nester(), 3)
 
-def test_main():
-    support.run_unittest(TestFuture)
-
 if __name__ == "__main__":
-    test_main()
+    unittest.main()
index c32f27f6161afdeeed3c98647d3a00ee17e446fa..413dd4d96b0367cc0572b2333359039c5ebd6266 100644 (file)
@@ -1,10 +1,6 @@
 from __future__ import unicode_literals
 
 import unittest
-from test import support
-
-def test_main():
-    pass
 
 if __name__ == "__main__":
-    test_main()
+    unittest.main()
index ed03a07037aaa15ffd22a4470953f36ecc3865ab..b44b97e63eea21d5274b6efb024eaca19ba1550b 100644 (file)
@@ -17,5 +17,5 @@ class TestMultipleFeatures(unittest.TestCase):
         self.assertEqual(s.getvalue(), "foo\n")
 
 
-def test_main():
-    support.run_unittest(TestMultipleFeatures)
+if __name__ == '__main__':
+    unittest.main()
index 76074e168dc57f9d5a59ebacb5fbc0cdea95b408..ef295b756e6a4771a9485c13f7ed4cfbd402988a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -644,6 +644,9 @@ Tests
 
 - Issue #15539: Added regression tests for Tools/scripts/pindent.py.
 
+- Issue #17303: test_future* now work with unittest test discovery.
+  Patch by Zachary Ware.
+
 - Issue #17163: test_file now works with unittest test discovery.
   Patch by Zachary Ware.