annotate Lib/test/test_future.py @ 39042:c02fa187e0f4 legacy-trunk

Part of SF patch #1484695. This removes dead code. The chksum was already verified in .frombuf() on the lines above. If there was a problem an exception is raised, so there was no way this condition could have been true.
author Neal Norwitz <nnorwitz@gmail.com>
date Mon, 10 Jul 2006 00:23:17 +0000
parents 47eaa38b29cb
children 3478c160207b 25bcdf3cd194 cc992d75d5b3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16839
e1b1e68cbd8c Add regression test for future statements. This adds eight files, but
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1 # Test various flavors of legal and illegal future statements
e1b1e68cbd8c Add regression test for future statements. This adds eight files, but
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2
31184
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
3 import unittest
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
4 from test import test_support
16839
e1b1e68cbd8c Add regression test for future statements. This adds eight files, but
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
5 import re
e1b1e68cbd8c Add regression test for future statements. This adds eight files, but
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
6
e1b1e68cbd8c Add regression test for future statements. This adds eight files, but
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
7 rx = re.compile('\((\S+).py, line (\d+)')
e1b1e68cbd8c Add regression test for future statements. This adds eight files, but
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
8
31184
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
9 def get_error_location(msg):
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
10 mo = rx.search(str(msg))
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
11 return mo.group(1, 2)
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
12
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
13 class FutureTest(unittest.TestCase):
16839
e1b1e68cbd8c Add regression test for future statements. This adds eight files, but
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
14
31184
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
15 def test_future1(self):
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
16 test_support.unload('test_future1')
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
17 from test import test_future1
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
18 self.assertEqual(test_future1.result, 6)
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
19
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
20 def test_future2(self):
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
21 test_support.unload('test_future2')
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
22 from test import test_future2
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
23 self.assertEqual(test_future2.result, 6)
16839
e1b1e68cbd8c Add regression test for future statements. This adds eight files, but
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
24
31184
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
25 def test_future3(self):
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
26 test_support.unload('test_future3')
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
27 from test import test_future3
16839
e1b1e68cbd8c Add regression test for future statements. This adds eight files, but
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
28
31184
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
29 def test_badfuture3(self):
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
30 try:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
31 from test import badsyntax_future3
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
32 except SyntaxError, msg:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
33 self.assertEqual(get_error_location(msg), ("badsyntax_future3", '3'))
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
34 else:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
35 self.fail("expected exception didn't occur")
16839
e1b1e68cbd8c Add regression test for future statements. This adds eight files, but
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
36
31184
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
37 def test_badfuture4(self):
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
38 try:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
39 from test import badsyntax_future4
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
40 except SyntaxError, msg:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
41 self.assertEqual(get_error_location(msg), ("badsyntax_future4", '3'))
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
42 else:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
43 self.fail("expected exception didn't occur")
19408
7e5e974b3d37 Fix SF bug [ #450245 ] Error in parsing future stmts
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 17558
diff changeset
44
31184
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
45 def test_badfuture5(self):
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
46 try:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
47 from test import badsyntax_future5
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
48 except SyntaxError, msg:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
49 self.assertEqual(get_error_location(msg), ("badsyntax_future5", '4'))
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
50 else:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
51 self.fail("expected exception didn't occur")
16839
e1b1e68cbd8c Add regression test for future statements. This adds eight files, but
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
52
31184
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
53 def test_badfuture6(self):
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
54 try:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
55 from test import badsyntax_future6
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
56 except SyntaxError, msg:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
57 self.assertEqual(get_error_location(msg), ("badsyntax_future6", '3'))
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
58 else:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
59 self.fail("expected exception didn't occur")
16839
e1b1e68cbd8c Add regression test for future statements. This adds eight files, but
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
60
31184
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
61 def test_badfuture7(self):
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
62 try:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
63 from test import badsyntax_future7
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
64 except SyntaxError, msg:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
65 self.assertEqual(get_error_location(msg), ("badsyntax_future7", '3'))
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
66 else:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
67 self.fail("expected exception didn't occur")
16839
e1b1e68cbd8c Add regression test for future statements. This adds eight files, but
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
68
31184
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
69 def test_badfuture8(self):
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
70 try:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
71 from test import badsyntax_future8
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
72 except SyntaxError, msg:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
73 self.assertEqual(get_error_location(msg), ("badsyntax_future8", '3'))
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
74 else:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
75 self.fail("expected exception didn't occur")
16839
e1b1e68cbd8c Add regression test for future statements. This adds eight files, but
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
76
31184
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
77 def test_badfuture9(self):
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
78 try:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
79 from test import badsyntax_future9
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
80 except SyntaxError, msg:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
81 self.assertEqual(get_error_location(msg), ("badsyntax_future9", '3'))
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
82 else:
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
83 self.fail("expected exception didn't occur")
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
84
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
85 def test_main():
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
86 test_support.run_unittest(FutureTest)
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
87
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
88 if __name__ == "__main__":
47eaa38b29cb SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald
Neal Norwitz <nnorwitz@gmail.com>
parents: 24442
diff changeset
89 test_main()