~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Alexander Belchenko
  • Date: 2007-01-04 23:36:44 UTC
  • mfrom: (2224 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2225.
  • Revision ID: bialix@ukr.net-20070104233644-7znkxoj9b0y7ev28
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
643
643
        self.assertEqual(None, os.environ.get('BZR_TEST_ENV_VAR'))
644
644
        self.failIf('BZR_TEST_ENV_VAR' in os.environ)
645
645
 
 
646
 
 
647
class TestLocalTimeOffset(TestCase):
 
648
 
 
649
    def test_local_time_offset(self):
 
650
        """Test that local_time_offset() returns a sane value."""
 
651
        offset = osutils.local_time_offset()
 
652
        self.assertTrue(isinstance(offset, int))
 
653
        # Test that the offset is no more than a eighteen hours in
 
654
        # either direction.
 
655
        # Time zone handling is system specific, so it is difficult to
 
656
        # do more specific tests, but a value outside of this range is
 
657
        # probably wrong.
 
658
        eighteen_hours = 18 * 3600
 
659
        self.assertTrue(-eighteen_hours < offset < eighteen_hours)
 
660
 
 
661
    def test_local_time_offset_with_timestamp(self):
 
662
        """Test that local_time_offset() works with a timestamp."""
 
663
        offset = osutils.local_time_offset(1000000000.1234567)
 
664
        self.assertTrue(isinstance(offset, int))
 
665
        eighteen_hours = 18 * 3600
 
666
        self.assertTrue(-eighteen_hours < offset < eighteen_hours)