diff options
author | Nikolaus Schulz <microschulz@web.de> | 2008-09-29 03:05:57 +0200 |
---|---|---|
committer | Nikolaus Schulz <microschulz@web.de> | 2010-07-19 01:13:24 +0200 |
commit | 9d9f13a4403d3e74655fb6ba2ae8964adcac313b (patch) | |
tree | fe80402eed66f81c784164262ec34317aadb8f97 | |
parent | 54821151e4f0a9a8891bbc3d4f1f552e00ca1c3a (diff) | |
download | archivemail-9d9f13a4403d3e74655fb6ba2ae8964adcac313b.tar.gz archivemail-9d9f13a4403d3e74655fb6ba2ae8964adcac313b.tar.bz2 archivemail-9d9f13a4403d3e74655fb6ba2ae8964adcac313b.zip |
test suite: account for lacking precision of os.utime()
os.utime() uses the utimes(2) system call to set file timestamps. utimes(2)
has a microsecond resolution, but stat(2) may return timestamps with
nanosecond resolution. So, the check that we have properly reset the mbox
file timestamp must allow a minor deviation.
-rwxr-xr-x | test_archivemail.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/test_archivemail.py b/test_archivemail.py index 8cbf152..01f2c01 100755 --- a/test_archivemail.py +++ b/test_archivemail.py @@ -69,6 +69,9 @@ except ImportError: print "Try renaming it from 'archivemail' to 'archivemail.py'." sys.exit(1) +# precision of os.utime() when restoring mbox timestamps +utimes_precision = 5 + class TestCaseInTempdir(unittest.TestCase): """Base class for testcases that need to create temporary files. @@ -642,8 +645,8 @@ class TestArchiveMboxTimestamp(TestCaseInTempdir): assert(os.path.exists(self.mbox_name)) new_atime = os.path.getatime(self.mbox_name) new_mtime = os.path.getmtime(self.mbox_name) - self.assertEqual(self.mtime, new_mtime) - self.assertEqual(self.atime, new_atime) + self.assertAlmostEqual(self.mtime, new_mtime, utimes_precision) + self.assertAlmostEqual(self.atime, new_atime, utimes_precision) def testMixed(self): """mbox timestamps should not change after semi-archival""" @@ -663,8 +666,8 @@ class TestArchiveMboxTimestamp(TestCaseInTempdir): assert(os.path.exists(self.mbox_name)) new_atime = os.path.getatime(self.mbox_name) new_mtime = os.path.getmtime(self.mbox_name) - self.assertEqual(self.mtime, new_mtime) - self.assertEqual(self.atime, new_atime) + self.assertAlmostEqual(self.mtime, new_mtime, utimes_precision) + self.assertAlmostEqual(self.atime, new_atime, utimes_precision) def testOld(self): """mbox timestamps should not change after archival""" @@ -684,8 +687,8 @@ class TestArchiveMboxTimestamp(TestCaseInTempdir): assert(os.path.exists(self.mbox_name)) new_atime = os.path.getatime(self.mbox_name) new_mtime = os.path.getmtime(self.mbox_name) - self.assertEqual(self.mtime, new_mtime) - self.assertEqual(self.atime, new_atime) + self.assertAlmostEqual(self.mtime, new_mtime, utimes_precision) + self.assertAlmostEqual(self.atime, new_atime, utimes_precision) def tearDown(self): archivemail.options.quiet = 0 |