summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-01-10 07:33:10 +0200
committerLars Wirzenius <liw@liw.fi>2020-01-10 08:11:23 +0200
commit8c583252d22856a47b5cdf30997cbae305b70f36 (patch)
tree847a91b7f859ce2f8770af934831a4f439097563 /templates
parent432a88a05bec355aff948cdbfef0bacd9c57db8e (diff)
downloadsubplot-8c583252d22856a47b5cdf30997cbae305b70f36.tar.gz
Add: remember original directory in Python code template
We create and chdir to a temporary directory, but the step function may need to refer to the original directory the test program is launched from.
Diffstat (limited to 'templates')
-rw-r--r--templates/python.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/templates/python.py b/templates/python.py
index c9d2018..067e316 100644
--- a/templates/python.py
+++ b/templates/python.py
@@ -19,6 +19,9 @@ class Context:
def __init__(self):
self._vars = {}
+ def as_dict(self):
+ return dict(self._vars)
+
def get(self, key, default=None):
return self._vars.get(key, default)
@@ -44,6 +47,11 @@ def get_file(filename):
def assert_eq(a, b):
assert a == b, 'expected %r == %r' % (a, b)
+# Remember where we started from. The step functions may need to refer
+# to files there.
+srcdir = os.getcwd()
+print('srcdir', srcdir)
+
# Create a new temporary directory and chdir there. This allows step
# functions to create new files in the current working directory
# without having to be so careful.