summaryrefslogtreecommitdiff
path: root/tests/helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/helpers.py')
-rw-r--r--tests/helpers.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/helpers.py b/tests/helpers.py
index 1420bed7..185f20dd 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -9,6 +9,7 @@ import glob
import os
import os.path
import re
+import shutil
import subprocess
import textwrap
@@ -95,6 +96,11 @@ def nice_file(*fparts):
return os.path.normcase(os.path.abspath(os.path.realpath(fname)))
+def os_sep(s):
+ """Replace slashes in `s` with the correct separator for the OS."""
+ return s.replace("/", os.sep)
+
+
class CheckUniqueFilenames:
"""Asserts the uniqueness of file names passed to a function."""
def __init__(self, wrapped):
@@ -156,6 +162,14 @@ def remove_files(*patterns):
for fname in glob.glob(pattern):
os.remove(fname)
+def remove_tree(dirname):
+ """Remove a directory tree.
+
+ It's fine for the directory to not exist in the first place.
+ """
+ if os.path.exists(dirname):
+ shutil.rmtree(dirname)
+
# Map chars to numbers for arcz_to_arcs
_arcz_map = {'.': -1}