summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Bourke <michael@iter8ve.com>2021-12-10 15:28:11 +1100
committerMichael Bourke <michael@iter8ve.com>2021-12-10 15:43:07 +1100
commit8ce4f91d7b539f322371de0bf7802a14f62d151c (patch)
treeedccd60d91d056002b2db236150bd0b5a682ae44
parent8c4ce94b7d075e8fe705bce9100d6b0bc3e816e6 (diff)
downloadmako-8ce4f91d7b539f322371de0bf7802a14f62d151c.tar.gz
Fix 3.7 and Windows problems
Change-Id: Iec9544a055a1a2e3e2a87b8dce8360ffa64a67c3
-rw-r--r--test/util/helpers.py12
-rw-r--r--tox.ini4
2 files changed, 13 insertions, 3 deletions
diff --git a/test/util/helpers.py b/test/util/helpers.py
index 0ca4c2d..86402c8 100644
--- a/test/util/helpers.py
+++ b/test/util/helpers.py
@@ -19,9 +19,19 @@ def result_lines(result):
]
+def _unlink_path(path, missing_ok=False):
+ # Replicate 3.8+ functionality in 3.7
+ cm = contextlib.nullcontext()
+ if missing_ok:
+ cm = contextlib.suppress(FileNotFoundError)
+
+ with cm:
+ path.unlink()
+
+
def replace_file_with_dir(pathspec):
path = pathlib.Path(pathspec)
- path.unlink(missing_ok=True)
+ _unlink_path(path, missing_ok=True)
path.mkdir(exist_ok=True)
return path
diff --git a/tox.ini b/tox.ini
index dc0530b..8b2b0d2 100644
--- a/tox.ini
+++ b/tox.ini
@@ -15,8 +15,8 @@ deps=pytest>=3.1.0
setenv=
cov: COVERAGE={[testenv]cov_args}
- TEST_TEMPLATE_BASE={toxinidir}/test/templates
- TEST_MODULE_BASE={env:TEST_TEMPLATE_BASE}/modules
+ TEST_TEMPLATE_BASE={toxinidir}{/}test{/}templates
+ TEST_MODULE_BASE={env:TEST_TEMPLATE_BASE}{/}modules
commands=pytest {env:COVERAGE:} {posargs}