'Test that timezone attributes respect the timezone as set by the
standard C{TZ} environment variable and L{tzset} API.'

def test_tzinfo(self):

    if (tzset is None):
        raise SkipTest('Platform    cannot    change    timezone;    unable    to    verify    offsets.')
    def testForTimeZone(name, expectedOffsetDST, expectedOffsetSTD):
        setTZ(name)
        localDST = mktime((2006, 6, 30, 0, 0, 0, 4, 181, 1))
        localSTD = mktime((2007, 1, 31, 0, 0, 0, 2, 31, 0))
        tzDST = FixedOffsetTimeZone.fromLocalTimeStamp(localDST)
        tzSTD = FixedOffsetTimeZone.fromLocalTimeStamp(localSTD)
        self.assertEqual(tzDST.tzname(localDST), 'UTC{0}'.format(expectedOffsetDST))
        self.assertEqual(tzSTD.tzname(localSTD), 'UTC{0}'.format(expectedOffsetSTD))
        self.assertEqual(tzDST.dst(localDST), timedelta(0))
        self.assertEqual(tzSTD.dst(localSTD), timedelta(0))
        def timeDeltaFromOffset(offset):
            assert (len(offset) == 5)
            sign = offset[0]
            hours = int(offset[1:3])
            minutes = int(offset[3:5])
            if (sign == '-'):
                hours = (- hours)
                minutes = (- minutes)
            else:
                assert (sign == '+')
            return timedelta(hours=hours, minutes=minutes)
        self.assertEqual(tzDST.utcoffset(localDST), timeDeltaFromOffset(expectedOffsetDST))
        self.assertEqual(tzSTD.utcoffset(localSTD), timeDeltaFromOffset(expectedOffsetSTD))
    addTZCleanup(self)
    testForTimeZone('UTC+00', '+0000', '+0000')
    testForTimeZone('EST+05EDT,M4.1.0,M10.5.0', '-0400', '-0500')
    testForTimeZone('CEST-01CEDT,M4.1.0,M10.5.0', '+0200', '+0100')
    testForTimeZone('CST+06', '-0600', '-0600')
