diff options
Diffstat (limited to 'Lib/test/test_future.py')
-rw-r--r-- | Lib/test/test_future.py | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/Lib/test/test_future.py b/Lib/test/test_future.py index 84f9c47d00b..c6689a1a18d 100644 --- a/Lib/test/test_future.py +++ b/Lib/test/test_future.py @@ -1,7 +1,7 @@ # Test various flavors of legal and illegal future statements import unittest -from test import test_support +from test import support import re rx = re.compile('\((\S+).py, line (\d+)') @@ -13,23 +13,23 @@ def get_error_location(msg): class FutureTest(unittest.TestCase): def test_future1(self): - test_support.unload('test_future1') + support.unload('test_future1') from test import test_future1 self.assertEqual(test_future1.result, 6) def test_future2(self): - test_support.unload('test_future2') + support.unload('test_future2') from test import test_future2 self.assertEqual(test_future2.result, 6) def test_future3(self): - test_support.unload('test_future3') + support.unload('test_future3') from test import test_future3 def test_badfuture3(self): try: from test import badsyntax_future3 - except SyntaxError, msg: + except SyntaxError as msg: self.assertEqual(get_error_location(msg), ("badsyntax_future3", '3')) else: self.fail("expected exception didn't occur") @@ -37,7 +37,7 @@ class FutureTest(unittest.TestCase): def test_badfuture4(self): try: from test import badsyntax_future4 - except SyntaxError, msg: + except SyntaxError as msg: self.assertEqual(get_error_location(msg), ("badsyntax_future4", '3')) else: self.fail("expected exception didn't occur") @@ -45,7 +45,7 @@ class FutureTest(unittest.TestCase): def test_badfuture5(self): try: from test import badsyntax_future5 - except SyntaxError, msg: + except SyntaxError as msg: self.assertEqual(get_error_location(msg), ("badsyntax_future5", '4')) else: self.fail("expected exception didn't occur") @@ -53,7 +53,7 @@ class FutureTest(unittest.TestCase): def test_badfuture6(self): try: from test import badsyntax_future6 - except SyntaxError, msg: + except SyntaxError as msg: self.assertEqual(get_error_location(msg), ("badsyntax_future6", '3')) else: self.fail("expected exception didn't occur") @@ -61,7 +61,7 @@ class FutureTest(unittest.TestCase): def test_badfuture7(self): try: from test import badsyntax_future7 - except SyntaxError, msg: + except SyntaxError as msg: self.assertEqual(get_error_location(msg), ("badsyntax_future7", '3')) else: self.fail("expected exception didn't occur") @@ -69,7 +69,7 @@ class FutureTest(unittest.TestCase): def test_badfuture8(self): try: from test import badsyntax_future8 - except SyntaxError, msg: + except SyntaxError as msg: self.assertEqual(get_error_location(msg), ("badsyntax_future8", '3')) else: self.fail("expected exception didn't occur") @@ -77,7 +77,7 @@ class FutureTest(unittest.TestCase): def test_badfuture9(self): try: from test import badsyntax_future9 - except SyntaxError, msg: + except SyntaxError as msg: self.assertEqual(get_error_location(msg), ("badsyntax_future9", '3')) else: self.fail("expected exception didn't occur") @@ -89,31 +89,31 @@ class FutureTest(unittest.TestCase): # the parser hack disabled. If a new keyword is introduced in # 2.6, change this to refer to the new future import. try: - exec "from __future__ import print_function; print 0" + exec("from __future__ import print_function; print 0") except SyntaxError: pass else: self.fail("syntax error didn't occur") try: - exec "from __future__ import (print_function); print 0" + exec("from __future__ import (print_function); print 0") except SyntaxError: pass else: self.fail("syntax error didn't occur") def test_multiple_features(self): - test_support.unload("test.test_future5") + support.unload("test.test_future5") from test import test_future5 def test_unicode_literals_exec(self): scope = {} - exec "from __future__ import unicode_literals; x = ''" in scope - self.assertIsInstance(scope["x"], unicode) + exec("from __future__ import unicode_literals; x = ''", {}, scope) + self.assertIsInstance(scope["x"], str) def test_main(): - test_support.run_unittest(FutureTest) + support.run_unittest(FutureTest) if __name__ == "__main__": test_main() |