Tim Peters | ffc215a | 2001-02-26 21:14:49 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | from test_support import verbose, verify |
| 3 | from types import TupleType, StringType, IntType |
| 4 | import __future__ |
| 5 | |
| 6 | GOOD_SERIALS = ("alpha", "beta", "candidate", "final") |
| 7 | |
| 8 | features = [x for x in dir(__future__) if x[:1] != "_"] |
| 9 | for feature in features: |
| 10 | value = getattr(__future__, feature) |
| 11 | if verbose: |
| 12 | print "Checking __future__ ", feature, "value", value |
Tim Peters | ffc215a | 2001-02-26 21:14:49 +0000 | [diff] [blame] | 13 | |
Tim Peters | d74bc43 | 2001-03-02 02:53:08 +0000 | [diff] [blame] | 14 | optional = value.getOptionalRelease() |
| 15 | mandatory = value.getMandatoryRelease() |
Tim Peters | ffc215a | 2001-02-26 21:14:49 +0000 | [diff] [blame] | 16 | |
| 17 | verify(type(optional) is TupleType, "optional isn't tuple") |
| 18 | verify(len(optional) == 5, "optional isn't 5-tuple") |
| 19 | major, minor, micro, level, serial = optional |
| 20 | verify(type(major) is IntType, "optional major isn't int") |
| 21 | verify(type(minor) is IntType, "optional minor isn't int") |
| 22 | verify(type(micro) is IntType, "optional micro isn't int") |
| 23 | verify(type(level) is StringType, "optional level isn't string") |
| 24 | verify(level in GOOD_SERIALS, |
| 25 | "optional level string has unknown value") |
| 26 | verify(type(serial) is IntType, "optional serial isn't int") |
| 27 | |
| 28 | verify(type(mandatory) is TupleType or |
| 29 | mandatory is None, "mandatory isn't tuple or None") |
| 30 | if mandatory is not None: |
| 31 | verify(len(mandatory) == 5, "mandatory isn't 5-tuple") |
| 32 | major, minor, micro, level, serial = mandatory |
| 33 | verify(type(major) is IntType, "mandatory major isn't int") |
| 34 | verify(type(minor) is IntType, "mandatory minor isn't int") |
| 35 | verify(type(micro) is IntType, "mandatory micro isn't int") |
| 36 | verify(type(level) is StringType, "mandatory level isn't string") |
| 37 | verify(level in GOOD_SERIALS, |
| 38 | "mandatory serial string has unknown value") |
| 39 | verify(type(serial) is IntType, "mandatory serial isn't int") |
| 40 | verify(optional < mandatory, |
| 41 | "optional not less than mandatory, and mandatory not None") |