Es kommt u.a. zu einem PermissionError wenn die Temorären Dateien gelöscht werden sollen.
Der relevante Code sieht ungefähr so aus:
Code: Alles auswählen
class TempDir():
def __init__(self, prefix=""):
self.tempfolder = tempfile.mkdtemp(prefix=prefix)
def __enter__(self):
return self.tempfolder
def __exit__(self, exc_type, exc_value, traceback):
shutil.rmtree(self.tempfolder)
class TestBoot(BaseExampleTestCase):
def test_boot_git_readonly(self):
with TempDir(prefix="bootstrap_test_boot_git_readonly_") as tempfolder:
# teste rum...
Code: Alles auswählen
ERROR: test_boot_git_readonly (bootstrap_env.tests.test_boot.TestBoot)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\bootstrap_env\src\bootstrap-env\bootstrap_env\tests\test_boot.py", line 175, in test_boot_git_readonly
self.assertIn("New python executable in %s/bin/python" % tempfolder, output)
File "C:\bootstrap_env\src\bootstrap-env\bootstrap_env\tests\utils\base_unittest.py", line 79, in __exit__
shutil.rmtree(self.tempfolder)
File "C:\Python27\Lib\shutil.py", line 247, in rmtree
rmtree(fullname, ignore_errors, onerror)
File "C:\Python27\Lib\shutil.py", line 247, in rmtree
rmtree(fullname, ignore_errors, onerror)
File "C:\Python27\Lib\shutil.py", line 247, in rmtree
rmtree(fullname, ignore_errors, onerror)
File "C:\Python27\Lib\shutil.py", line 247, in rmtree
rmtree(fullname, ignore_errors, onerror)
File "C:\Python27\Lib\shutil.py", line 247, in rmtree
rmtree(fullname, ignore_errors, onerror)
File "C:\Python27\Lib\shutil.py", line 252, in rmtree
onerror(os.remove, fullname, sys.exc_info())
File "C:\Python27\Lib\shutil.py", line 250, in rmtree
os.remove(fullname)
WindowsError: [Error 5] Access is denied: 'c:\\users\\appveyor\\appdata\\local\\temp\\bootstrap_test_boot_git_readonly_nak2xk\\src\\bootstrap-env\\.git\\objects\\pack\\pack-cf9c2d47351e4132d8a4a99bef0ec17482170ccd.idx'
Lokal auf 8.1 so:
Code: Alles auswählen
Traceback (most recent call last):
File "V:\workspace\bootstrap-env\bootstrap_env\tests\test_boot.py", line 187,
in test_boot_git_readonly
self.assertIn("Successfully installed bootstrap-env", log_content)
File "V:\workspace\bootstrap-env\bootstrap_env\tests\utils\base_unittest.py",
line 79, in __exit__
shutil.rmtree(self.tempfolder)
File "C:\Users\jens\AppData\Roaming\bootstrap_env\lib\shutil.py", line 478, in
rmtree
return _rmtree_unsafe(path, onerror)
File "C:\Users\jens\AppData\Roaming\bootstrap_env\lib\shutil.py", line 368, in
_rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Users\jens\AppData\Roaming\bootstrap_env\lib\shutil.py", line 368, in
_rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Users\jens\AppData\Roaming\bootstrap_env\lib\shutil.py", line 368, in
_rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Users\jens\AppData\Roaming\bootstrap_env\lib\shutil.py", line 368, in
_rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Users\jens\AppData\Roaming\bootstrap_env\lib\shutil.py", line 368, in
_rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Users\jens\AppData\Roaming\bootstrap_env\lib\shutil.py", line 373, in
_rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
File "C:\Users\jens\AppData\Roaming\bootstrap_env\lib\shutil.py", line 371, in
_rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 5] Zugriff verweigert: 'x:\\temp\\bootstrap_test_boot
_git_readonly_c99_odba\\src\\bootstrap-env\\.git\\objects\\pack\\pack-267165bf5a
6c86d4637de920e960efb67356a872.idx'Also einmal WindowsError und einmal PermissionError :K
Überlege gerade, ob ich mit atexit aufräumen sollte?!?
(Wobei ich erstmal den Fehler ignorieren werde...)
