Unittest - Make is easier to reset env vars of task and taskd

This commit is contained in:
Renato Alves
2014-07-18 13:58:15 +01:00
parent 2a198d59fe
commit 02683aecd7
2 changed files with 22 additions and 11 deletions

View File

@@ -57,10 +57,7 @@ class Taskd(object):
# Ensure any instance is properly destroyed at session end
atexit.register(lambda: self.destroy())
# Copy all env variables to avoid clashing subprocess environments
self.env = os.environ.copy()
# Make sure TASKDDATA points to the temporary folder
self.env["TASKDATA"] = self.datadir
self.reset_env()
if certpath is None:
certpath = DEFAULT_CERT_PATH
@@ -101,6 +98,15 @@ class Taskd(object):
txt = super(Taskd, self).__repr__()
return "{0} running from {1}>".format(txt[:-1], self.datadir)
def reset_env(self):
"""Set a new environment derived from the one used to launch the test
"""
# Copy all env variables to avoid clashing subprocess environments
self.env = os.environ.copy()
# Make sure TASKDDATA points to the temporary folder
self.env["TASKDATA"] = self.datadir
def create_user(self, user=None, group=None, org=None):
"""Create a user/group in the server and return the user
credentials to use in a taskw client.