2 from test_support
import verbose
, verify
3 from types
import TupleType
, StringType
, IntType
6 GOOD_SERIALS
= ("alpha", "beta", "candidate", "final")
8 features
= __future__
.all_feature_names
10 # Verify that all_feature_names appears correct.
11 given_feature_names
= features
[:]
12 for name
in dir(__future__
):
13 obj
= getattr(__future__
, name
, None)
14 if obj
is not None and isinstance(obj
, __future__
._Feature
):
15 verify(name
in given_feature_names
,
16 "%r should have been in all_feature_names" % name
)
17 given_feature_names
.remove(name
)
18 verify(len(given_feature_names
) == 0,
19 "all_feature_names has too much: %r" % given_feature_names
)
20 del given_feature_names
22 for feature
in features
:
23 value
= getattr(__future__
, feature
)
25 print "Checking __future__ ", feature
, "value", value
27 optional
= value
.getOptionalRelease()
28 mandatory
= value
.getMandatoryRelease()
30 verify(type(optional
) is TupleType
, "optional isn't tuple")
31 verify(len(optional
) == 5, "optional isn't 5-tuple")
32 major
, minor
, micro
, level
, serial
= optional
33 verify(type(major
) is IntType
, "optional major isn't int")
34 verify(type(minor
) is IntType
, "optional minor isn't int")
35 verify(type(micro
) is IntType
, "optional micro isn't int")
36 verify(type(level
) is StringType
, "optional level isn't string")
37 verify(level
in GOOD_SERIALS
,
38 "optional level string has unknown value")
39 verify(type(serial
) is IntType
, "optional serial isn't int")
41 verify(type(mandatory
) is TupleType
or
42 mandatory
is None, "mandatory isn't tuple or None")
43 if mandatory
is not None:
44 verify(len(mandatory
) == 5, "mandatory isn't 5-tuple")
45 major
, minor
, micro
, level
, serial
= mandatory
46 verify(type(major
) is IntType
, "mandatory major isn't int")
47 verify(type(minor
) is IntType
, "mandatory minor isn't int")
48 verify(type(micro
) is IntType
, "mandatory micro isn't int")
49 verify(type(level
) is StringType
, "mandatory level isn't string")
50 verify(level
in GOOD_SERIALS
,
51 "mandatory serial string has unknown value")
52 verify(type(serial
) is IntType
, "mandatory serial isn't int")
53 verify(optional
< mandatory
,
54 "optional not less than mandatory, and mandatory not None")
56 verify(hasattr(value
, "compiler_flag"),
57 "feature is missing a .compiler_flag attr")
58 verify(type(getattr(value
, "compiler_flag")) is IntType
,
59 ".compiler_flag isn't int")