Created
March 31, 2015 00:04
-
-
Save garrettr/90c2ffb142f3ee69da20 to your computer and use it in GitHub Desktop.
Example shutil.rmtree test failure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=================================== FAILURES =================================== | |
____________________ TestIntegration.test_delete_collection ____________________ | |
self = <tests.test_unit_integration.TestIntegration testMethod=test_delete_collection> | |
def tearDown(self): | |
> common.shared_teardown() | |
tests/test_unit_integration.py:84: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
tests/common.py:79: in shared_teardown | |
clean_root() | |
tests/common.py:14: in clean_root | |
shutil.rmtree(config.SECUREDROP_DATA_ROOT) | |
/usr/lib/python2.7/shutil.py:245: in rmtree | |
rmtree(fullname, ignore_errors, onerror) | |
/usr/lib/python2.7/shutil.py:250: in rmtree | |
onerror(os.remove, fullname, sys.exc_info()) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
path = '/tmp/securedrop/keys', ignore_errors = False | |
onerror = <function onerror at 0x399d848> | |
def rmtree(path, ignore_errors=False, onerror=None): | |
"""Recursively delete a directory tree. | |
If ignore_errors is set, errors are ignored; otherwise, if onerror | |
is set, it is called to handle the error with arguments (func, | |
path, exc_info) where func is os.listdir, os.remove, or os.rmdir; | |
path is the argument to that function that caused it to fail; and | |
exc_info is a tuple returned by sys.exc_info(). If ignore_errors | |
is false and onerror is None, an exception is raised. | |
""" | |
if ignore_errors: | |
def onerror(*args): | |
pass | |
elif onerror is None: | |
def onerror(*args): | |
raise | |
try: | |
if os.path.islink(path): | |
# symlinks to directories are forbidden, see bug #1669 | |
raise OSError("Cannot call rmtree on a symbolic link") | |
except OSError: | |
onerror(os.path.islink, path, sys.exc_info()) | |
# can't continue even if onerror hook returns | |
return | |
names = [] | |
try: | |
names = os.listdir(path) | |
except os.error, err: | |
onerror(os.listdir, path, sys.exc_info()) | |
for name in names: | |
fullname = os.path.join(path, name) | |
try: | |
mode = os.lstat(fullname).st_mode | |
except os.error: | |
mode = 0 | |
if stat.S_ISDIR(mode): | |
rmtree(fullname, ignore_errors, onerror) | |
else: | |
try: | |
> os.remove(fullname) | |
E OSError: [Errno 2] No such file or directory: '/tmp/securedrop/keys/pubring.gpg.lock' | |
/usr/lib/python2.7/shutil.py:248: OSError | |
----------------------------- Captured stderr call ----------------------------- | |
00:01:39 RQ worker started, version 0.4.6 | |
00:01:39 | |
00:01:39 *** Listening on default... | |
________________________ TestSource.test_submit_message ________________________ | |
self = <tests.test_unit_source.TestSource testMethod=test_submit_message> | |
def tearDown(self): | |
> common.shared_teardown() | |
tests/test_unit_source.py:26: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
tests/common.py:79: in shared_teardown | |
clean_root() | |
tests/common.py:14: in clean_root | |
shutil.rmtree(config.SECUREDROP_DATA_ROOT) | |
/usr/lib/python2.7/shutil.py:245: in rmtree | |
rmtree(fullname, ignore_errors, onerror) | |
/usr/lib/python2.7/shutil.py:250: in rmtree | |
onerror(os.remove, fullname, sys.exc_info()) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
path = '/tmp/securedrop/keys', ignore_errors = False | |
onerror = <function onerror at 0x34a0de8> | |
def rmtree(path, ignore_errors=False, onerror=None): | |
"""Recursively delete a directory tree. | |
If ignore_errors is set, errors are ignored; otherwise, if onerror | |
is set, it is called to handle the error with arguments (func, | |
path, exc_info) where func is os.listdir, os.remove, or os.rmdir; | |
path is the argument to that function that caused it to fail; and | |
exc_info is a tuple returned by sys.exc_info(). If ignore_errors | |
is false and onerror is None, an exception is raised. | |
""" | |
if ignore_errors: | |
def onerror(*args): | |
pass | |
elif onerror is None: | |
def onerror(*args): | |
raise | |
try: | |
if os.path.islink(path): | |
# symlinks to directories are forbidden, see bug #1669 | |
raise OSError("Cannot call rmtree on a symbolic link") | |
except OSError: | |
onerror(os.path.islink, path, sys.exc_info()) | |
# can't continue even if onerror hook returns | |
return | |
names = [] | |
try: | |
names = os.listdir(path) | |
except os.error, err: | |
onerror(os.listdir, path, sys.exc_info()) | |
for name in names: | |
fullname = os.path.join(path, name) | |
try: | |
mode = os.lstat(fullname).st_mode | |
except os.error: | |
mode = 0 | |
if stat.S_ISDIR(mode): | |
rmtree(fullname, ignore_errors, onerror) | |
else: | |
try: | |
> os.remove(fullname) | |
E OSError: [Errno 2] No such file or directory: '/tmp/securedrop/keys/.#lk0x7f187816dac0.testing-worker-linux-e7a62211-2-2367-linux-7-56489264.17090' | |
/usr/lib/python2.7/shutil.py:248: OSError | |
----------------------------- Captured stderr call ----------------------------- | |
Exception in thread Thread-562: | |
Traceback (most recent call last): | |
File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner | |
self.run() | |
File "/usr/lib/python2.7/threading.py", line 504, in run | |
self.__target(*self.__args, **self.__kwargs) | |
File "/usr/local/lib/python2.7/dist-packages/gnupg/_meta.py", line 541, in _read_response | |
result._handle_status(keyword, value) | |
File "/usr/local/lib/python2.7/dist-packages/gnupg/_parsers.py", line 860, in _handle_status | |
raise ValueError("Unknown status message: %r" % key) | |
ValueError: Unknown status message: u'ERROR' | |
===================== 2 failed, 42 passed in 17.10 seconds ===================== | |
Exception in thread Thread-606: | |
Traceback (most recent call last): | |
File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner | |
self.run() | |
File "/usr/lib/python2.7/threading.py", line 504, in run | |
self.__target(*self.__args, **self.__kwargs) | |
File "/usr/local/lib/python2.7/dist-packages/gnupg/_meta.py", line 541, in _read_response | |
result._handle_status(keyword, value) | |
File "/usr/local/lib/python2.7/dist-packages/gnupg/_parsers.py", line 860, in _handle_status | |
raise ValueError("Unknown status message: %r" % key) | |
ValueError: Unknown status message: u'ERROR' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment