0001 #! /usr/bin/env python 0002 from test.test_support import verbose, verify 0003 from types import TupleType, StringType, IntType 0004 import __future__ 0005 0006 GOOD_SERIALS = ("alpha", "beta", "candidate", "final") 0007 0008 features = __future__.all_feature_names 0009 0010 # Verify that all_feature_names appears correct. 0011 given_feature_names = features[:] 0012 for name in dir(__future__): 0013 obj = getattr(__future__, name, None) 0014 if obj is not None and isinstance(obj, __future__._Feature): 0015 verify(name in given_feature_names, 0016 "%r should have been in all_feature_names" % name) 0017 given_feature_names.remove(name) 0018 verify(len(given_feature_names) == 0, 0019 "all_feature_names has too much: %r" % given_feature_names) 0020 del given_feature_names 0021 0022 for feature in features: 0023 value = getattr(__future__, feature) 0024 if verbose: 0025 print "Checking __future__ ", feature, "value", value 0026 0027 optional = value.getOptionalRelease() 0028 mandatory = value.getMandatoryRelease() 0029 0030 verify(type(optional) is TupleType, "optional isn't tuple") 0031 verify(len(optional) == 5, "optional isn't 5-tuple") 0032 major, minor, micro, level, serial = optional 0033 verify(type(major) is IntType, "optional major isn't int") 0034 verify(type(minor) is IntType, "optional minor isn't int") 0035 verify(type(micro) is IntType, "optional micro isn't int") 0036 verify(isinstance(level, basestring), "optional level isn't string") 0037 verify(level in GOOD_SERIALS, 0038 "optional level string has unknown value") 0039 verify(type(serial) is IntType, "optional serial isn't int") 0040 0041 verify(type(mandatory) is TupleType or 0042 mandatory is None, "mandatory isn't tuple or None") 0043 if mandatory is not None: 0044 verify(len(mandatory) == 5, "mandatory isn't 5-tuple") 0045 major, minor, micro, level, serial = mandatory 0046 verify(type(major) is IntType, "mandatory major isn't int") 0047 verify(type(minor) is IntType, "mandatory minor isn't int") 0048 verify(type(micro) is IntType, "mandatory micro isn't int") 0049 verify(isinstance(level, basestring), "mandatory level isn't string") 0050 verify(level in GOOD_SERIALS, 0051 "mandatory serial string has unknown value") 0052 verify(type(serial) is IntType, "mandatory serial isn't int") 0053 verify(optional < mandatory, 0054 "optional not less than mandatory, and mandatory not None") 0055 0056 verify(hasattr(value, "compiler_flag"), 0057 "feature is missing a .compiler_flag attr") 0058 verify(type(getattr(value, "compiler_flag")) is IntType, 0059 ".compiler_flag isn't int") 0060
Generated by PyXR 0.9.4