summaryrefslogtreecommitdiffstats
path: root/QMTest
diff options
context:
space:
mode:
authorGreg Noel <GregNoel@tigris.org>2010-04-15 00:02:59 (GMT)
committerGreg Noel <GregNoel@tigris.org>2010-04-15 00:02:59 (GMT)
commit9931fe6c59d330d0dbeea1c51456e3a9f94377d8 (patch)
tree0e17c9808475e40bfad54db43529ad01d411e6c2 /QMTest
parent12ec17eedc70ee82421b27ff7dd84e947d4e6953 (diff)
downloadSCons-9931fe6c59d330d0dbeea1c51456e3a9f94377d8.zip
SCons-9931fe6c59d330d0dbeea1c51456e3a9f94377d8.tar.gz
SCons-9931fe6c59d330d0dbeea1c51456e3a9f94377d8.tar.bz2
http://scons.tigris.org/issues/show_bug.cgi?id=2345
Apply the first part of the 'raise' fixer (the three-argument cases are not converted and will need to wait until native support of with_traceback() is available).
Diffstat (limited to 'QMTest')
-rw-r--r--QMTest/TestCmd.py10
-rw-r--r--QMTest/TestSCons.py4
-rw-r--r--QMTest/unittest.py23
3 files changed, 18 insertions, 19 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py
index 0139b29..6f53892 100644
--- a/QMTest/TestCmd.py
+++ b/QMTest/TestCmd.py
@@ -438,7 +438,7 @@ def match_re(lines = None, res = None):
expr = re.compile(s)
except re.error, e:
msg = "Regular expression error in %s: %s"
- raise re.error, msg % (repr(s), e[0])
+ raise re.error(msg % (repr(s), e[0]))
if not expr.search(lines[i]):
return
return 1
@@ -455,7 +455,7 @@ def match_re_dotall(lines = None, res = None):
expr = re.compile(s, re.DOTALL)
except re.error, e:
msg = "Regular expression error in %s: %s"
- raise re.error, msg % (repr(s), e[0])
+ raise re.error(msg % (repr(s), e[0]))
if expr.match(lines):
return 1
@@ -511,7 +511,7 @@ def diff_re(a, b, fromfile='', tofile='',
expr = re.compile(s)
except re.error, e:
msg = "Regular expression error in %s: %s"
- raise re.error, msg % (repr(s), e[0])
+ raise re.error(msg % (repr(s), e[0]))
if not expr.search(bline):
result.append("%sc%s" % (i+1, i+1))
result.append('< ' + repr(a[i]))
@@ -1128,7 +1128,7 @@ class TestCmd(object):
"""
file = self.canonicalize(file)
if mode[0] != 'r':
- raise ValueError, "mode must begin with 'r'"
+ raise ValueError("mode must begin with 'r'")
return open(file, mode).read()
def rmdir(self, dir):
@@ -1586,7 +1586,7 @@ class TestCmd(object):
"""
file = self.canonicalize(file)
if mode[0] != 'w':
- raise ValueError, "mode must begin with 'w'"
+ raise ValueError("mode must begin with 'w'")
open(file, mode).write(content)
# Local Variables:
diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py
index b7e019d..d61c008 100644
--- a/QMTest/TestSCons.py
+++ b/QMTest/TestSCons.py
@@ -813,7 +813,7 @@ SConscript( sconscript )
def matchPart(log, logfile, lastEnd, NoMatch=NoMatch):
m = re.match(log, logfile[lastEnd:])
if not m:
- raise NoMatch, lastEnd
+ raise NoMatch(lastEnd)
return m.end() + lastEnd
try:
#print len(os.linesep)
@@ -888,7 +888,7 @@ SConscript( sconscript )
log = ""
if doCheckLog: lastEnd = matchPart(ls, logfile, lastEnd)
if doCheckLog and lastEnd != len(logfile):
- raise NoMatch, lastEnd
+ raise NoMatch(lastEnd)
except NoMatch, m:
print "Cannot match log file against log regexp."
diff --git a/QMTest/unittest.py b/QMTest/unittest.py
index 476c1fc..1d87c15 100644
--- a/QMTest/unittest.py
+++ b/QMTest/unittest.py
@@ -124,8 +124,8 @@ class TestCase:
try:
self.__testMethod = getattr(self,methodName)
except AttributeError:
- raise ValueError, "no such test method in %s: %s" % \
- (self.__class__, methodName)
+ raise ValueError("no such test method in %s: %s" % \
+ (self.__class__, methodName))
def setUp(self):
"Hook method for setting up the test fixture before exercising it."
@@ -199,7 +199,7 @@ class TestCase:
__debug__ is false.
"""
if not expr:
- raise AssertionError, msg
+ raise AssertionError(msg)
failUnless = assert_
@@ -222,11 +222,11 @@ class TestCase:
else:
if hasattr(excClass,'__name__'): excName = excClass.__name__
else: excName = str(excClass)
- raise AssertionError, excName
+ raise AssertionError(excName)
def fail(self, msg=None):
"""Fail immediately, with the given message."""
- raise AssertionError, msg
+ raise AssertionError(msg)
def __exc_info(self):
"""Return a version of sys.exc_info() with the traceback frame
@@ -376,7 +376,7 @@ def createTestInstance(name, module=None):
"""
spec = name.split(':')
- if len(spec) > 2: raise ValueError, "illegal test name: %s" % name
+ if len(spec) > 2: raise ValueError("illegal test name: %s" % name)
if len(spec) == 1:
testName = spec[0]
caseName = None
@@ -385,7 +385,7 @@ def createTestInstance(name, module=None):
parts = testName.split('.')
if module is None:
if len(parts) < 2:
- raise ValueError, "incomplete test name: %s" % name
+ raise ValueError("incomplete test name: %s" % name)
constructor = __import__('.'.join(parts[:-1]))
parts = parts[1:]
else:
@@ -393,20 +393,19 @@ def createTestInstance(name, module=None):
for part in parts:
constructor = getattr(constructor, part)
if not callable(constructor):
- raise ValueError, "%s is not a callable object" % constructor
+ raise ValueError("%s is not a callable object" % constructor)
if caseName:
if caseName[-1] == '-':
prefix = caseName[:-1]
if not prefix:
- raise ValueError, "prefix too short: %s" % name
+ raise ValueError("prefix too short: %s" % name)
test = makeSuite(constructor, prefix=prefix)
else:
test = constructor(caseName)
else:
test = constructor()
if not hasattr(test,"countTestCases"):
- raise TypeError, \
- "object %s found with spec %s is not a test" % (test, name)
+ raise TypeError("object %s found with spec %s is not a test" % (test, name))
return test
@@ -662,7 +661,7 @@ Examples:
if opt in ('-h','-H','--help'):
self.usageExit()
if len(args) == 0 and self.defaultTest is None:
- raise getopt.error, "No default test is defined."
+ raise getopt.error("No default test is defined.")
if len(args) > 0:
self.testNames = args
else: