Eugene Mineev avatar Eugene Mineev committed ae45a57

Add function for processing the file system errors.

In some points git creates files with read-only attribute. And the situation can not be resolved automatically without the processing function.

Comments (0)

Files changed (1)


 from __future__ import with_statement
 import unittest, doctest
 import os, shutil, os.path
-import gitapi 
+import gitapi
+import stat
+def onfserror(delegate, path, exec_info):
+    if not os.access(path, os.W_OK):
+        os.chmod(path, stat.S_IWUSR)
+        delegate(path)
+    else:
+        raise
 class TestGitAPI(unittest.TestCase):
     """Tests for
             setattr(cls, "assertEquals", cls.assertEqual)
             setattr(cls, "assertNotEquals", cls.assertNotEqual)
         if os.path.exists("./test"):
-            shutil.rmtree("./test")
+            shutil.rmtree("./test", onerror=onfserror)
         assert os.path.exists("./test")
     def tearDownClass(self):
-        shutil.rmtree("test")
+        shutil.rmtree("test", onerror=onfserror)
     def test_005_Init(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.