Browse Source

[master] Fix test: remove sleep, use fake mtime

Jelte Jansen 12 years ago
parent
commit
50b124aea4
1 changed files with 3 additions and 4 deletions
  1. 3 4
      src/bin/cmdctl/tests/cmdctl_test.py

+ 3 - 4
src/bin/cmdctl/tests/cmdctl_test.py

@@ -580,12 +580,11 @@ class TestSecureHTTPServer(unittest.TestCase):
             self.server._create_user_info(accounts_file)
             self.assertEqual(fake_users_val, self.server._user_infos)
 
-        # Yes sleep sucks, but in this case we need it to check for
-        # a changed mtime, not for some thread to do its work
-        # (do we run these tests on systems with 1+ secs mtimes?)
-        time.sleep(0.1)
         # create the file again, this time read should not be a noop
         with TmpTextFile(accounts_file, ['otherroot,foo,bar']):
+            # Set mtime in future
+            stat = os.stat(accounts_file)
+            os.utime(accounts_file, (stat.st_atime, stat.st_mtime + 10))
             self.server._create_user_info(accounts_file)
             self.assertEqual(1, len(self.server._user_infos))
             self.assertTrue('otherroot' in self.server._user_infos)