]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.2/Lib/test/test___future__.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / test / test___future__.py
CommitLineData
4710c53d 1#! /usr/bin/env python\r
2import unittest\r
3from test import test_support\r
4import __future__\r
5\r
6GOOD_SERIALS = ("alpha", "beta", "candidate", "final")\r
7\r
8features = __future__.all_feature_names\r
9\r
10class FutureTest(unittest.TestCase):\r
11\r
12 def test_names(self):\r
13 # Verify that all_feature_names appears correct.\r
14 given_feature_names = features[:]\r
15 for name in dir(__future__):\r
16 obj = getattr(__future__, name, None)\r
17 if obj is not None and isinstance(obj, __future__._Feature):\r
18 self.assertTrue(\r
19 name in given_feature_names,\r
20 "%r should have been in all_feature_names" % name\r
21 )\r
22 given_feature_names.remove(name)\r
23 self.assertEqual(len(given_feature_names), 0,\r
24 "all_feature_names has too much: %r" % given_feature_names)\r
25\r
26 def test_attributes(self):\r
27 for feature in features:\r
28 value = getattr(__future__, feature)\r
29\r
30 optional = value.getOptionalRelease()\r
31 mandatory = value.getMandatoryRelease()\r
32\r
33 a = self.assertTrue\r
34 e = self.assertEqual\r
35 def check(t, name):\r
36 a(isinstance(t, tuple), "%s isn't tuple" % name)\r
37 e(len(t), 5, "%s isn't 5-tuple" % name)\r
38 (major, minor, micro, level, serial) = t\r
39 a(isinstance(major, int), "%s major isn't int" % name)\r
40 a(isinstance(minor, int), "%s minor isn't int" % name)\r
41 a(isinstance(micro, int), "%s micro isn't int" % name)\r
42 a(isinstance(level, basestring),\r
43 "%s level isn't string" % name)\r
44 a(level in GOOD_SERIALS,\r
45 "%s level string has unknown value" % name)\r
46 a(isinstance(serial, int), "%s serial isn't int" % name)\r
47\r
48 check(optional, "optional")\r
49 if mandatory is not None:\r
50 check(mandatory, "mandatory")\r
51 a(optional < mandatory,\r
52 "optional not less than mandatory, and mandatory not None")\r
53\r
54 a(hasattr(value, "compiler_flag"),\r
55 "feature is missing a .compiler_flag attr")\r
56 # Make sure the compile accepts the flag.\r
57 compile("", "<test>", "exec", value.compiler_flag)\r
58 a(isinstance(getattr(value, "compiler_flag"), int),\r
59 ".compiler_flag isn't int")\r
60\r
61\r
62def test_main():\r
63 test_support.run_unittest(FutureTest)\r
64\r
65if __name__ == "__main__":\r
66 test_main()\r