Index: tools/tests/base_unittest.py |
diff --git a/tools/tests/base_unittest.py b/tools/tests/base_unittest.py |
index 2adaed0b70d050b1769c6e207bf9809952470d5a..f7ee570a246cc5a0f6e74ffba8868746927585e3 100755 |
--- a/tools/tests/base_unittest.py |
+++ b/tools/tests/base_unittest.py |
@@ -10,7 +10,9 @@ A wrapper around the standard Python unittest library, adding features we need |
for various unittests within this directory. |
""" |
+import errno |
import os |
+import shutil |
import sys |
import unittest |
@@ -26,6 +28,20 @@ class TestCase(unittest.TestCase): |
"""Tell unittest framework to not print docstrings for test cases.""" |
return None |
+ def create_empty_dir(self, path): |
+ """Creates an empty directory at path and returns path. |
+ |
+ Args: |
+ path: path on local disk |
+ """ |
+ shutil.rmtree(path=path, ignore_errors=True) |
+ try: |
+ os.makedirs(path) |
+ except OSError as exc: |
+ if exc.errno != errno.EEXIST: |
+ raise |
+ return path |
+ |
def run_command(self, args): |
"""Runs a program from the command line and returns stdout. |