ソースを参照

Squelch errors in test_index under windows

Koen Martens 8 年 前
コミット
221e4530b5
2 ファイル変更10 行追加5 行削除
  1. 5 0
      NEWS
  2. 5 5
      dulwich/tests/test_index.py

+ 5 - 0
NEWS

@@ -1,5 +1,10 @@
 0.16.4	UNRELEASED
 
+ TEST FIXES
+
+ * Skip test that requires sync to synchronize filesystems if os.sync is
+   not available. (Koen Martens)
+
 0.16.3	2016-01-14
 
  TEST FIXES

+ 5 - 5
dulwich/tests/test_index.py

@@ -368,8 +368,8 @@ class BuildIndexTests(TestCase):
             self.assertEqual(['d'],
                 sorted(os.listdir(os.path.join(repo.path, 'c'))))
 
+    @skipIf(not getattr(os, 'sync', None), 'Requires sync support')
     def test_norewrite(self):
-        sync = getattr(os, 'sync', lambda: os.system('sync'))
         repo_dir = tempfile.mkdtemp()
         self.addCleanup(shutil.rmtree, repo_dir)
         with Repo.init(repo_dir) as repo:
@@ -386,25 +386,25 @@ class BuildIndexTests(TestCase):
             build_index_from_tree(repo.path, repo.index_path(),
                                   repo.object_store, tree.id)
             # Use sync as metadata can be cached on some FS
-            sync()
+            os.sync()
             mtime = os.stat(filea_path).st_mtime
 
             # Test Rewrite
             build_index_from_tree(repo.path, repo.index_path(),
                                   repo.object_store, tree.id)
-            sync()
+            os.sync()
             self.assertEqual(mtime, os.stat(filea_path).st_mtime)
 
             # Modify content
             with open(filea_path, 'wb') as fh:
                 fh.write(b'test a')
-            sync()
+            os.sync()
             mtime = os.stat(filea_path).st_mtime
 
             # Test rewrite
             build_index_from_tree(repo.path, repo.index_path(),
                                   repo.object_store, tree.id)
-            sync()
+            os.sync()
             with open(filea_path, 'rb') as fh:
                 self.assertEqual(b'file a', fh.read())