~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_timestamp.py

  • Committer: Patch Queue Manager
  • Date: 2016-02-01 19:13:13 UTC
  • mfrom: (6614.2.2 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20160201191313-wdfvmfff1djde6oq
(vila) Release 2.7.0 (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2009, 2011 Canonical Ltd
 
1
# Copyright (C) 2007, 2009, 2010, 2011, 2016 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
102
102
class UnpackHighresDateTests(tests.TestCase):
103
103
 
104
104
    def test_unpack_highres_date(self):
105
 
        self.assertEquals(
 
105
        self.assertEqual(
106
106
            (1120153132.3508501, -18000),
107
107
            timestamp.unpack_highres_date('Thu 2005-06-30 12:38:52.350850105 -0500'))
108
 
        self.assertEquals(
 
108
        self.assertEqual(
109
109
            (1120153132.3508501, 0),
110
110
            timestamp.unpack_highres_date('Thu 2005-06-30 17:38:52.350850105 +0000'))
111
 
        self.assertEquals(
 
111
        self.assertEqual(
112
112
            (1120153132.3508501, 7200),
113
113
            timestamp.unpack_highres_date('Thu 2005-06-30 19:38:52.350850105 +0200'))
114
 
        self.assertEquals(
 
114
        self.assertEqual(
115
115
            (1152428738.867522, 19800),
116
116
            timestamp.unpack_highres_date('Sun 2006-07-09 12:35:38.867522001 +0530'))
117
117
 
119
119
        t = time.time()
120
120
        o = local_time_offset()
121
121
        t2, o2 = timestamp.unpack_highres_date(timestamp.format_highres_date(t, o))
122
 
        self.assertEquals(t, t2)
123
 
        self.assertEquals(o, o2)
 
122
        self.assertEqual(t, t2)
 
123
        self.assertEqual(o, o2)
124
124
        t -= 24*3600*365*2 # Start 2 years ago
125
125
        o = -12*3600
126
126
        for count in xrange(500):
128
128
            o = ((o/3600 + 13) % 25 - 12)*3600 # Add 1 wrap around from [-12, 12]
129
129
            date = timestamp.format_highres_date(t, o)
130
130
            t2, o2 = timestamp.unpack_highres_date(date)
131
 
            self.assertEquals(t, t2,
 
131
            self.assertEqual(t, t2,
132
132
                'Failed on date %r, %s,%s diff:%s' % (date, t, o, t2-t))
133
 
            self.assertEquals(o, o2,
 
133
            self.assertEqual(o, o2,
134
134
                'Failed on date %r, %s,%s diff:%s' % (date, t, o, t2-t))