summaryrefslogtreecommitdiff
path: root/templates/python/template.py
diff options
context:
space:
mode:
Diffstat (limited to 'templates/python/template.py')
-rw-r--r--templates/python/template.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/templates/python/template.py b/templates/python/template.py
index a1fa3ee..4ceeb51 100644
--- a/templates/python/template.py
+++ b/templates/python/template.py
@@ -156,6 +156,7 @@ class Scenario:
scendir = tempfile.mkdtemp(dir=_datadir)
os.chdir(scendir)
+ os.environ['HOME'] = scendir
ctx = Context()
done = []
@@ -216,6 +217,17 @@ def parse_command_line():
return p.parse_args()
+def setup_minimal_environment():
+ minimal = {
+ 'PATH': '/bin:/usr/bin',
+ 'SHELL': '/bin/sh',
+ 'HOME': '/', # will be set to datadir for each scenario
+ }
+
+ os.environ.clear()
+ os.environ.update(minimal)
+
+
def setup_logging(args):
if args.log:
fmt = "%(asctime)s %(levelname)s %(message)s"
@@ -243,6 +255,7 @@ def save_directory(dirname, tarname):
def main():
args = parse_command_line()
+ setup_minimal_environment()
setup_logging(args)
logging.info("Test program starts")