summaryrefslogtreecommitdiffstats
path: root/QMTest
diff options
context:
space:
mode:
authorGreg Noel <GregNoel@tigris.org>2010-03-27 07:39:52 (GMT)
committerGreg Noel <GregNoel@tigris.org>2010-03-27 07:39:52 (GMT)
commit59ed0a109bf5add2efcef459080837b11066c6fb (patch)
treefff879b4f9676a72e16c0f7b4dd969f050038b4f /QMTest
parent00a3188193ba1feef927cf18e7f5fc20ad71b848 (diff)
downloadSCons-59ed0a109bf5add2efcef459080837b11066c6fb.zip
SCons-59ed0a109bf5add2efcef459080837b11066c6fb.tar.gz
SCons-59ed0a109bf5add2efcef459080837b11066c6fb.tar.bz2
http://scons.tigris.org/issues/show_bug.cgi?id=2329
Applied a number of idiomatic changes. Uses of the 'sort()' method were converted into calls of 'sorted()' when possible and the sorted() expression was inserted into a subsequent statement whenever that made sense. The statement 'while 1:' was changed to 'while True:'. Names from the 'types' module (e.g., 'types.FooType') were converted to the equivalent build-in type (e.g., 'foo'). Comparisons between types were changed to use 'isinstance()'.
Diffstat (limited to 'QMTest')
-rw-r--r--QMTest/TestCmd.py26
-rw-r--r--QMTest/TestCommon.py3
-rw-r--r--QMTest/TestSCons.py6
-rw-r--r--QMTest/scons_tdb.py4
-rw-r--r--QMTest/unittest.py2
5 files changed, 18 insertions, 23 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py
index 163a78d..7c8e1a5 100644
--- a/QMTest/TestCmd.py
+++ b/QMTest/TestCmd.py
@@ -229,7 +229,6 @@ import sys
import tempfile
import time
import traceback
-import types
import UserList
__all__ = [
@@ -250,7 +249,7 @@ except ImportError:
__all__.append('simple_diff')
def is_List(e):
- return type(e) is types.ListType \
+ return isinstance(e, list) \
or isinstance(e, UserList.UserList)
try:
@@ -259,14 +258,15 @@ except ImportError:
class UserString:
pass
-if hasattr(types, 'UnicodeType'):
+try: unicode
+except NameError:
def is_String(e):
- return type(e) is types.StringType \
- or type(e) is types.UnicodeType \
- or isinstance(e, UserString)
+ return isinstance(e, str) or isinstance(e, UserString)
else:
def is_String(e):
- return type(e) is types.StringType or isinstance(e, UserString)
+ return isinstance(e, str) \
+ or isinstance(e, unicode) \
+ or isinstance(e, UserString)
tempfile.template = 'testcmd.'
if os.name in ('posix', 'nt'):
@@ -440,9 +440,9 @@ def match_re(lines = None, res = None):
def match_re_dotall(lines = None, res = None):
"""
"""
- if not type(lines) is type(""):
+ if not isinstance(lines, str):
lines = "\n".join(lines)
- if not type(res) is type(""):
+ if not isinstance(res, str):
res = "\n".join(res)
s = "^" + res + "$"
try:
@@ -997,21 +997,21 @@ class TestCmd(object):
interpreter = None,
arguments = None):
if program:
- if type(program) == type('') and not os.path.isabs(program):
+ if isinstance(program, str) and not os.path.isabs(program):
program = os.path.join(self._cwd, program)
else:
program = self.program
if not interpreter:
interpreter = self.interpreter
- if not type(program) in [type([]), type(())]:
+ if not type(program) in [list, tuple]:
program = [program]
cmd = list(program)
if interpreter:
- if not type(interpreter) in [type([]), type(())]:
+ if not type(interpreter) in [list, tuple]:
interpreter = [interpreter]
cmd = list(interpreter) + cmd
if arguments:
- if type(arguments) == type(''):
+ if isinstance(arguments, str):
arguments = arguments.split()
cmd.extend(arguments)
return cmd
diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py
index e9ae6a4..6b452f7 100644
--- a/QMTest/TestCommon.py
+++ b/QMTest/TestCommon.py
@@ -98,7 +98,6 @@ import os
import os.path
import stat
import sys
-import types
import UserList
from TestCmd import *
@@ -172,7 +171,7 @@ else:
dll_suffix = '.so'
def is_List(e):
- return type(e) is types.ListType \
+ return isinstance(e, list) \
or isinstance(e, UserList.UserList)
def is_writable(f):
diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py
index 38f2c92..a1ec227 100644
--- a/QMTest/TestSCons.py
+++ b/QMTest/TestSCons.py
@@ -515,9 +515,7 @@ class TestSCons(TestCommon):
import glob
result = []
for p in patterns:
- paths = glob.glob(p)
- paths.sort()
- result.extend(paths)
+ result.extend(sorted(glob.glob(p)))
return result
@@ -770,7 +768,7 @@ else:
self.QT_LIB_DIR = self.workpath(dir, 'lib')
def Qt_create_SConstruct(self, place):
- if type(place) is type([]):
+ if isinstance(place, list):
place = test.workpath(*place)
self.write(place, """\
if ARGUMENTS.get('noqtdir', 0): QTDIR=None
diff --git a/QMTest/scons_tdb.py b/QMTest/scons_tdb.py
index 73e8430..b5788c0 100644
--- a/QMTest/scons_tdb.py
+++ b/QMTest/scons_tdb.py
@@ -397,9 +397,7 @@ class AegisBatchStream(FileResultStream):
self._outcomes[test_id] = exit_status
def Summarize(self):
self.file.write('test_result = [\n')
- file_names = self._outcomes.keys()
- file_names.sort()
- for file_name in file_names:
+ for file_name in sorted(self._outcomes.keys()):
exit_status = self._outcomes[file_name]
file_name = file_name.replace('\\', '/')
self.file.write(' { file_name = "%s";\n' % file_name)
diff --git a/QMTest/unittest.py b/QMTest/unittest.py
index e5a8668..476c1fc 100644
--- a/QMTest/unittest.py
+++ b/QMTest/unittest.py
@@ -633,7 +633,7 @@ Examples:
"""
def __init__(self, module='__main__', defaultTest=None,
argv=None, testRunner=None):
- if type(module) == type(''):
+ if isinstance(module, str):
self.module = __import__(module)
for part in module.split('.')[1:]:
self.module = getattr(self.module, part)