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