Module: check_mk
Branch: master
Commit: b4edc6abaf670c1d0f0a84dbcc572b395c962e07
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b4edc6abaf670c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jul 27 15:00:10 2017 +0200
Fixed "new" bakery tests
Change-Id: Id002d42ed044e4a02df35f7257c408224cecb5cf
---
tests/testlib/__init__.py | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/tests/testlib/__init__.py b/tests/testlib/__init__.py
index 6d46076..9e84cf5 100644
--- a/tests/testlib/__init__.py
+++ b/tests/testlib/__init__.py
@@ -275,56 +275,60 @@ class Site(object):
return subprocess.call(cmd)
+ def path(self, rel_path):
+ return os.path.join(self.root, rel_path)
+
+
def read_file(self, rel_path):
if not self._is_running_as_site_user():
- p = self.execute(["cat", "%s/%s" % (self.root,
rel_path)], stdout=subprocess.PIPE)
+ p = self.execute(["cat", self.path(rel_path)],
stdout=subprocess.PIPE)
if p.wait() != 0:
raise Exception("Failed to read file %s. Exit-Code: %d" %
(rel_path, p.wait()))
return p.stdout.read()
else:
- return open("%s/%s" % (self.root, rel_path)).read()
+ return open(self.path(rel_path)).read()
def delete_file(self, rel_path):
if not self._is_running_as_site_user():
- p = self.execute(["rm", "-f", "%s/%s" %
(self.root, rel_path)])
+ p = self.execute(["rm", "-f", self.path(rel_path)])
if p.wait() != 0:
raise Exception("Failed to delete file %s. Exit-Code: %d" %
(rel_path, p.wait()))
else:
- os.unlink("%s/%s" % (self.root, rel_path))
+ os.unlink(self.path(rel_path))
def delete_dir(self, rel_path):
if not self._is_running_as_site_user():
- p = self.execute(["rm", "-rf", "%s/%s" %
(self.root, rel_path)])
+ p = self.execute(["rm", "-rf", self.path(rel_path)])
if p.wait() != 0:
raise Exception("Failed to delete directory %s. Exit-Code: %d"
% (rel_path, p.wait()))
else:
- shutil.rmtree("%s/%s" % (self.root, rel_path))
+ shutil.rmtree(self.path(rel_path))
def write_file(self, rel_path, content):
if not self._is_running_as_site_user():
- p = self.execute(["tee", "%s/%s" % (self.root,
rel_path)],
+ p = self.execute(["tee", self.path(rel_path)],
stdin=subprocess.PIPE, stdout=open(os.devnull,
"w"))
p.communicate(content)
p.stdin.close()
if p.wait() != 0:
raise Exception("Failed to write file %s. Exit-Code: %d" %
(rel_path, p.wait()))
else:
- return open("%s/%s" % (self.root, rel_path),
"w").write(content)
+ return open(self.path(rel_path), "w").write(content)
def file_exists(self, rel_path):
if not self._is_running_as_site_user():
- p = self.execute(["test", "-e", "%s/%s" %
(self.root, rel_path)], stdout=subprocess.PIPE)
+ p = self.execute(["test", "-e", self.path(rel_path)],
stdout=subprocess.PIPE)
return p.wait() == 0
else:
- return os.path.exists("%s/%s" % (self.root, rel_path))
+ return os.path.exists(self.path(rel_path))
def makedirs(self, rel_path):
- p = self.execute(["mkdir", "-p", "%s/%s" %
(self.root, rel_path)])
+ p = self.execute(["mkdir", "-p", self.path(rel_path)])
return p.wait() == 0