Browse Source

atime unit test: hardcode "round" timestamps

just to avoid rounding / precision issues with floating point computations on py < 3.3
I used 2 hardcoded "full second" values on the input file and check if they get restored
correctly.
Thomas Waldmann 9 years ago
parent
commit
765999195d
1 changed files with 4 additions and 2 deletions
  1. 4 2
      borg/testsuite/archiver.py

+ 4 - 2
borg/testsuite/archiver.py

@@ -288,14 +288,16 @@ class ArchiverTestCase(ArchiverTestCaseBase):
 
 
     def test_atime(self):
     def test_atime(self):
         have_root = self.create_test_files()
         have_root = self.create_test_files()
+        atime, mtime = 123456780, 234567890
+        os.utime('input/file1', (atime, mtime))
         self.cmd('init', self.repository_location)
         self.cmd('init', self.repository_location)
         self.cmd('create', self.repository_location + '::test', 'input')
         self.cmd('create', self.repository_location + '::test', 'input')
         with changedir('output'):
         with changedir('output'):
             self.cmd('extract', self.repository_location + '::test')
             self.cmd('extract', self.repository_location + '::test')
         sti = os.stat('input/file1')
         sti = os.stat('input/file1')
         sto = os.stat('output/input/file1')
         sto = os.stat('output/input/file1')
-        assert st_mtime_ns(sti) == st_mtime_ns(sto)
-        assert st_atime_ns(sti) == st_atime_ns(sto)
+        assert st_mtime_ns(sti) == st_mtime_ns(sto) == mtime * 1e9
+        assert st_atime_ns(sti) == st_atime_ns(sto) == atime * 1e9
 
 
     def _extract_repository_id(self, path):
     def _extract_repository_id(self, path):
         return Repository(self.repository_path).id
         return Repository(self.repository_path).id