annotate Lib/test/test___future__.py @ 78069:a8aa77458e12 3.2

Add c_size_t and c_ssize_t to the ctypes summary table.
author Antoine Pitrou <solipsis@pitrou.net>
date Thu, 12 Jul 2012 20:31:50 +0200
parents 3c9232a684ae
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
59522
fcfe324663a6 convert shebang lines: python -> python3
Benjamin Peterson <benjamin@python.org>
parents: 55061
diff changeset
1 #! /usr/bin/env python3
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
2 import unittest
47201
9c930a32cebb #2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents: 43577
diff changeset
3 from test import support
16770
14affbd03750 Add __future__.py to std library, + dull test to verify that assignments
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
4 import __future__
14affbd03750 Add __future__.py to std library, + dull test to verify that assignments
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
5
14affbd03750 Add __future__.py to std library, + dull test to verify that assignments
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
6 GOOD_SERIALS = ("alpha", "beta", "candidate", "final")
14affbd03750 Add __future__.py to std library, + dull test to verify that assignments
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
7
19345
38be177bd493 A self-contained piece of Michael Hudson's patch
Tim Peters <tim.peters@gmail.com>
parents: 16929
diff changeset
8 features = __future__.all_feature_names
19371
2bf2690966ff Expose the CO_xxx flags via the "new" module (re-solving a problem "the
Tim Peters <tim.peters@gmail.com>
parents: 19345
diff changeset
9
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
10 class FutureTest(unittest.TestCase):
19371
2bf2690966ff Expose the CO_xxx flags via the "new" module (re-solving a problem "the
Tim Peters <tim.peters@gmail.com>
parents: 19345
diff changeset
11
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
12 def test_names(self):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
13 # Verify that all_feature_names appears correct.
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
14 given_feature_names = features[:]
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
15 for name in dir(__future__):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
16 obj = getattr(__future__, name, None)
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
17 if obj is not None and isinstance(obj, __future__._Feature):
55593
0bb232078b8c Merged revisions 73715 via svnmerge from
Georg Brandl <georg@python.org>
parents: 55062
diff changeset
18 self.assertTrue(
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
19 name in given_feature_names,
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
20 "%r should have been in all_feature_names" % name
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
21 )
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
22 given_feature_names.remove(name)
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
23 self.assertEqual(len(given_feature_names), 0,
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
24 "all_feature_names has too much: %r" % given_feature_names)
16770
14affbd03750 Add __future__.py to std library, + dull test to verify that assignments
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
25
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
26 def test_attributes(self):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
27 for feature in features:
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
28 value = getattr(__future__, feature)
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
29
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
30 optional = value.getOptionalRelease()
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
31 mandatory = value.getMandatoryRelease()
16770
14affbd03750 Add __future__.py to std library, + dull test to verify that assignments
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
32
55593
0bb232078b8c Merged revisions 73715 via svnmerge from
Georg Brandl <georg@python.org>
parents: 55062
diff changeset
33 a = self.assertTrue
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
34 e = self.assertEqual
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
35 def check(t, name):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
36 a(isinstance(t, tuple), "%s isn't tuple" % name)
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
37 e(len(t), 5, "%s isn't 5-tuple" % name)
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
38 (major, minor, micro, level, serial) = t
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
39 a(isinstance(major, int), "%s major isn't int" % name)
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
40 a(isinstance(minor, int), "%s minor isn't int" % name)
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
41 a(isinstance(micro, int), "%s micro isn't int" % name)
43577
ace45b361e87 Patch# 1258 by Christian Heimes: kill basestring.
Guido van Rossum <guido@python.org>
parents: 40450
diff changeset
42 a(isinstance(level, str),
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
43 "%s level isn't string" % name)
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
44 a(level in GOOD_SERIALS,
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
45 "%s level string has unknown value" % name)
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
46 a(isinstance(serial, int), "%s serial isn't int" % name)
16770
14affbd03750 Add __future__.py to std library, + dull test to verify that assignments
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
47
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
48 check(optional, "optional")
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
49 if mandatory is not None:
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
50 check(mandatory, "mandatory")
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
51 a(optional < mandatory,
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
52 "optional not less than mandatory, and mandatory not None")
19345
38be177bd493 A self-contained piece of Michael Hudson's patch
Tim Peters <tim.peters@gmail.com>
parents: 16929
diff changeset
53
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
54 a(hasattr(value, "compiler_flag"),
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
55 "feature is missing a .compiler_flag attr")
55062
65e41bcbc25d Merged revisions 73782-73784 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 47201
diff changeset
56 # Make sure the compile accepts the flag.
65e41bcbc25d Merged revisions 73782-73784 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 47201
diff changeset
57 compile("", "<test>", "exec", value.compiler_flag)
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
58 a(isinstance(getattr(value, "compiler_flag"), int),
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
59 ".compiler_flag isn't int")
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
60
55062
65e41bcbc25d Merged revisions 73782-73784 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 47201
diff changeset
61
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
62 def test_main():
47201
9c930a32cebb #2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents: 43577
diff changeset
63 support.run_unittest(FutureTest)
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
64
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
65 if __name__ == "__main__":
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 26140
diff changeset
66 test_main()