summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-06-22 21:45:55 +0200
committerDan McGee <dan@archlinux.org>2011-06-24 08:36:48 +0200
commit11d8418737d9d9c12584c6eed83bc6cea46ef3e9 (patch)
tree90a3b7370bf7a45150d1f59780043758c05c92ba /test
parent763d638ca1d3f1f1d6a8276e36b837e82890f4ee (diff)
downloadpacman-11d8418737d9d9c12584c6eed83bc6cea46ef3e9.tar.gz
pacman-11d8418737d9d9c12584c6eed83bc6cea46ef3e9.tar.xz
pactest: small cleanups and chmod -x most files
Remove empty docstrings, small and easy pylint fixes, etc. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'test')
-rwxr-xr-xtest/pacman/pactest.py20
-rw-r--r--[-rwxr-xr-x]test/pacman/pmdb.py2
-rw-r--r--[-rwxr-xr-x]test/pacman/pmenv.py26
-rw-r--r--[-rwxr-xr-x]test/pacman/pmfile.py0
-rw-r--r--[-rwxr-xr-x]test/pacman/pmpkg.py0
-rw-r--r--[-rwxr-xr-x]test/pacman/pmrule.py0
-rw-r--r--[-rwxr-xr-x]test/pacman/pmtest.py19
-rw-r--r--[-rwxr-xr-x]test/pacman/util.py13
8 files changed, 23 insertions, 57 deletions
diff --git a/test/pacman/pactest.py b/test/pacman/pactest.py
index 77f87da6..62034dc7 100755
--- a/test/pacman/pactest.py
+++ b/test/pacman/pactest.py
@@ -30,10 +30,10 @@ import util
__author__ = "Aurelien FORET"
__version__ = "0.4"
-def resolveBinPath(option, opt_str, value, parser):
+def resolve_binary_path(option, opt_str, value, parser):
setattr(parser.values, option.dest, os.path.abspath(value))
-def globTests(option, opt_str, value, parser):
+def glob_tests(option, opt_str, value, parser):
idx = 0
globlist = []
@@ -46,8 +46,7 @@ def globTests(option, opt_str, value, parser):
parser.rargs = parser.rargs[idx:]
setattr(parser.values, option.dest, globlist)
-def createOptParser():
- testcases = []
+def create_parser():
usage = "usage: %prog [options] [[--test <path/to/testfile.py>] ...]"
description = "Runs automated tests on the pacman binary. Tests are " \
"described using an easy python syntax, and several can be " \
@@ -61,11 +60,11 @@ def createOptParser():
dest = "debug", default = 0,
help = "set debug level for pacman")
parser.add_option("-p", "--pacman", action = "callback",
- callback = resolveBinPath, type = "string",
+ callback = resolve_binary_path, type = "string",
dest = "bin", default = "pacman",
help = "specify location of the pacman binary")
parser.add_option("-t", "--test", action = "callback",
- callback = globTests, dest = "testcases",
+ callback = glob_tests, dest = "testcases",
help = "specify test case(s)")
parser.add_option("--keep-root", action = "store_true",
dest = "keeproot", default = False,
@@ -89,7 +88,7 @@ if __name__ == "__main__":
# instantiate env and parser objects
root_path = tempfile.mkdtemp()
env = pmenv.pmenv(root=root_path)
- opt_parser = createOptParser()
+ opt_parser = create_parser()
(opts, args) = opt_parser.parse_args()
# add parsed options to env object
@@ -113,13 +112,12 @@ if __name__ == "__main__":
env.run()
env.results()
- if env.failed > 0:
- print "pacman testing root saved: %s" % root_path
- sys.exit(1)
-
if not opts.keeproot:
shutil.rmtree(root_path)
else:
print "pacman testing root saved: %s" % root_path
+ if env.failed > 0:
+ sys.exit(1)
+
# vim: set ts=4 sw=4 et:
diff --git a/test/pacman/pmdb.py b/test/pacman/pmdb.py
index d07e4bd5..cff3358f 100755..100644
--- a/test/pacman/pmdb.py
+++ b/test/pacman/pmdb.py
@@ -40,7 +40,7 @@ def _mkfilelist(files):
name = util.getfilename(f)
file_set.add(name)
while "/" in name:
- [name, tmp] = name.rsplit("/", 1)
+ name, tmp = name.rsplit("/", 1)
file_set.add(name + "/")
return sorted(file_set)
diff --git a/test/pacman/pmenv.py b/test/pacman/pmenv.py
index 40444829..e9950fe8 100755..100644
--- a/test/pacman/pmenv.py
+++ b/test/pacman/pmenv.py
@@ -17,7 +17,6 @@
import os
-import os.path
import pmtest
@@ -102,35 +101,39 @@ class pmenv(object):
tfailed.append(test)
def _printtest(t):
- success = test.result["success"]
- fail = test.result["fail"]
- rules = len(test.rules)
+ success = t.result["success"]
+ fail = t.result["fail"]
+ rules = len(t.rules)
if fail == 0:
result = "[PASS]"
else:
result = "[FAIL]"
print result,
print "%s Rules: OK = %2u FAIL = %2u SKIP = %2u" \
- % (test.testname.ljust(34), success, fail, \
+ % (t.testname.ljust(34), success, fail, \
rules - (success + fail))
if fail != 0:
# print test description if test failed
- print " ", test.description
+ print " ", t.description
print "=========="*8
print "Results"
print "----------"*8
print " Passed:"
- for test in tpassed: _printtest(test)
+ for test in tpassed:
+ _printtest(test)
print "----------"*8
print " Expected Failures:"
- for test in texpectedfail: _printtest(test)
+ for test in texpectedfail:
+ _printtest(test)
print "----------"*8
print " Unexpected Passes:"
- for test in tunexpectedpass: _printtest(test)
+ for test in tunexpectedpass:
+ _printtest(test)
print "----------"*8
print " Failed:"
- for test in tfailed: _printtest(test)
+ for test in tfailed:
+ _printtest(test)
print "----------"*8
total = len(self.testcases)
@@ -142,7 +145,4 @@ class pmenv(object):
print "Fail = %3u (%6.2f%%)" % (self.failed, float(self.failed) * 100 / total)
print ""
-if __name__ == "__main__":
- pass
-
# vim: set ts=4 sw=4 et:
diff --git a/test/pacman/pmfile.py b/test/pacman/pmfile.py
index bd03a24e..bd03a24e 100755..100644
--- a/test/pacman/pmfile.py
+++ b/test/pacman/pmfile.py
diff --git a/test/pacman/pmpkg.py b/test/pacman/pmpkg.py
index 3d2a6cf4..3d2a6cf4 100755..100644
--- a/test/pacman/pmpkg.py
+++ b/test/pacman/pmpkg.py
diff --git a/test/pacman/pmrule.py b/test/pacman/pmrule.py
index 0f6ae602..0f6ae602 100755..100644
--- a/test/pacman/pmrule.py
+++ b/test/pacman/pmrule.py
diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py
index 82dfda6d..64e56da7 100755..100644
--- a/test/pacman/pmtest.py
+++ b/test/pacman/pmtest.py
@@ -17,7 +17,6 @@
import os
-import os.path
import shutil
import stat
import time
@@ -44,15 +43,11 @@ class pmtest(object):
"root = %s" % (self.name, self.testname, self.root)
def addpkg2db(self, treename, pkg):
- """
- """
if not treename in self.db:
self.db[treename] = pmdb.pmdb(treename, self.root)
self.db[treename].pkgs.append(pkg)
def addpkg(self, pkg):
- """
- """
self.localpkgs.append(pkg)
def findpkg(self, name, version, allow_local=False):
@@ -72,15 +67,10 @@ class pmtest(object):
return None
def addrule(self, rulename):
- """
- """
rule = pmrule.pmrule(rulename)
self.rules.append(rule)
def load(self):
- """
- """
-
# Reset test parameters
self.result = {
"success": 0,
@@ -111,9 +101,6 @@ class pmtest(object):
raise IOError("file %s does not exist!" % self.name)
def generate(self):
- """
- """
-
print "==> Generating test environment"
# Cleanup leftover files from a previous test session
@@ -206,9 +193,6 @@ class pmtest(object):
vprint("\t%s" % f.name)
def run(self, pacman):
- """
- """
-
if os.path.isfile(util.PM_LOCK):
print "\tERROR: another pacman session is on-going -- skipping"
return
@@ -274,9 +258,6 @@ class pmtest(object):
print "\tERROR: pacman dumped a core file"
def check(self):
- """
- """
-
print "==> Checking rules"
for i in self.rules:
diff --git a/test/pacman/util.py b/test/pacman/util.py
index ddd955a2..bc8e3500 100755..100644
--- a/test/pacman/util.py
+++ b/test/pacman/util.py
@@ -49,10 +49,7 @@ def vprint(msg):
#
def getfilename(name):
- """
- """
filename = name
- extra = ""
if filename[-1] == "*":
filename = filename.rstrip("*")
if filename.find(" -> ") != -1:
@@ -62,8 +59,6 @@ def getfilename(name):
return filename
def mkfile(name, data = ""):
- """
- """
isdir = 0
islink = 0
setperms = 0
@@ -108,8 +103,6 @@ def mkfile(name, data = ""):
os.chmod(filename, int(perms, 8))
def mkinstallfile(filename, install):
- """
- """
data = []
for key, value in install.iteritems():
if value:
@@ -118,8 +111,6 @@ def mkinstallfile(filename, install):
mkfile(filename, "\n".join(data))
def mkcfgfile(filename, root, option, db):
- """
- """
# Options
data = ["[options]"]
for key, value in option.iteritems():
@@ -147,8 +138,6 @@ def mkcfgfile(filename, root, option, db):
#
def getmd5sum(filename):
- """
- """
if not os.path.isfile(filename):
return ""
fd = open(filename, "rb")
@@ -162,8 +151,6 @@ def getmd5sum(filename):
return checksum.hexdigest()
def mkmd5sum(data):
- """
- """
checksum = hashlib.md5()
checksum.update("%s\n" % data)
return checksum.hexdigest()