Print target path and class during failed test clean-up
@@ -6,13 +6,6 @@ import shutil
import tempfile
from unittest import TestCase
-
-def remove_tree(rootdir):
- # Remove every directory starting with rootdir
- for dirpath in glob.glob(rootdir + "*"):
- shutil.rmtree(dirpath)
-
-
class DiskTestCase(TestCase):
def setUp(self):
@@ -20,7 +13,14 @@ class DiskTestCase(TestCase):
self.rootdir = tempfile.mkdtemp(prefix=prefix)
def tearDown(self):
- remove_tree(self.rootdir)
+ # Remove every directory starting with rootdir
+ for dirpath in glob.glob(self.rootdir + "*"):
+ try:
+ shutil.rmtree(dirpath)
+ except OSError as exc:
+ print("test '{}' error deleting '{}'".format(self.__class__.__name__,
+ dirpath))
+ raise
def path(self, path):
return os.path.abspath(os.path.join(self.rootdir, path))
