Rev 4944: Rework the tests a bit. in http://bazaar.launchpad.net/~jameinel/bzr/2.1.0rc1-set-mtime

John Arbash Meinel john at arbash-meinel.com
Wed Jan 6 20:18:22 GMT 2010


At http://bazaar.launchpad.net/~jameinel/bzr/2.1.0rc1-set-mtime

------------------------------------------------------------
revno: 4944
revision-id: john at arbash-meinel.com-20100106201757-lhu6vhuanzg7io61
parent: john at arbash-meinel.com-20100106200816-micwvc3rqtcv2hr1
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1.0rc1-set-mtime
timestamp: Wed 2010-01-06 14:17:57 -0600
message:
  Rework the tests a bit.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py	2010-01-06 19:59:02 +0000
+++ b/bzrlib/tests/test_osutils.py	2010-01-06 20:17:57 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
+# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -2022,10 +2022,11 @@
         # precision limitations on older filesystems such as FAT, but try to
         # use functions that have at least microsecond resolution (1us on
         # POSIX, 100ns on Windows)
-        self.assertFalse(int((new_mtime - set_mtime) / 2),
+        self.assertTrue(abs(set_mtime - new_mtime) < 2.0,
             "%r != %r within two seconds" % (new_mtime, set_mtime))
 
     def test_fset_mtime(self):
         self._check_fset_mtime(osutils.fset_mtime)
-        if osutils.fset_mtime is not osutils._utime_fset_mtime:
-            self._check_fset_mtime(osutils._utime_fset_mtime)
+
+    def test__utime_fset_mtime(self):
+        self._check_fset_mtime(osutils._utime_fset_mtime)

=== modified file 'bzrlib/tests/test_transform.py'
--- a/bzrlib/tests/test_transform.py	2010-01-06 19:59:02 +0000
+++ b/bzrlib/tests/test_transform.py	2010-01-06 20:17:57 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd
+# Copyright (C) 2006, 2007, 2008, 2009, 2010 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -143,7 +143,7 @@
         self.addCleanup(self.wt.unlock)
         # Roll back the clock, so that we know everything is being set to the
         # exact time
-        transform._creation_mtime = creation_mtime = time.time() - 10.0
+        transform._creation_mtime = creation_mtime = time.time() - 20.0
         transform.create_file('content-one',
                               transform.create_path('one', root))
         time.sleep(1) # *ugly*
@@ -155,8 +155,8 @@
         fo, st2 = self.wt.get_file_with_stat(None, path='two', filtered=False)
         fo.close()
         # We only guarantee 2s resolution
-        self.assertFalse(int((creation_mtime - st1.st_mtime) / 2),
-            "%r != %r within two seconds" % (creation_mtime, st1.st_mtime))
+        self.assertTrue(abs(new_time - set_mtime) < 2
+            "%s != %s within 2 seconds" % (creation_mtime, st1.st_mtime))
         # But if we have more than that, all files should get the same result
         self.assertEqual(st1.st_mtime, st2.st_mtime)
 



More information about the bazaar-commits mailing list