9 class ArvadosBaseTestCase(unittest.TestCase):
10 # This class provides common utility functions for our tests.
16 for workdir in self._tempdirs:
17 shutil.rmtree(workdir, ignore_errors=True)
19 def make_tmpdir(self):
20 self._tempdirs.append(tempfile.mkdtemp())
21 return self._tempdirs[-1]
23 def data_file(self, filename):
25 basedir = os.path.dirname(__file__)
28 return open(os.path.join(basedir, 'data', filename))
30 def build_directory_tree(self, tree):
31 tree_root = self.make_tmpdir()
33 path = os.path.join(tree_root, leaf)
35 os.makedirs(os.path.dirname(path))
36 except OSError as error:
37 if error.errno != errno.EEXIST:
39 with open(path, 'w') as tmpfile:
43 def make_test_file(self, text="test"):
44 testfile = tempfile.NamedTemporaryFile()