diff options
Diffstat (limited to 'QMTest')
-rw-r--r-- | QMTest/TestCmd.py | 24 | ||||
-rw-r--r-- | QMTest/TestCommon.py | 10 |
2 files changed, 16 insertions, 18 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 1ee5d4e..1c71907 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -228,7 +228,12 @@ import sys import tempfile import time import traceback -import UserList +try: + from collections import UserList, UserString +except ImportError: + # no 'collections' module or no UserFoo in collections + exec('from UserList import UserList') + exec('from UserString import UserString') try: # pre-2.7 doesn't have the memoryview() built-in @@ -264,24 +269,15 @@ except ImportError: __all__.append('simple_diff') def is_List(e): - return isinstance(e, list) \ - or isinstance(e, UserList.UserList) - -try: - from UserString import UserString -except ImportError: - class UserString: - pass + return isinstance(e, (list,UserList)) -try: unicode +try: eval('unicode') except NameError: def is_String(e): - return isinstance(e, str) or isinstance(e, UserString) + return isinstance(e, (str,UserString)) else: def is_String(e): - return isinstance(e, str) \ - or isinstance(e, unicode) \ - or isinstance(e, UserString) + return isinstance(e, (str,unicode,UserString)) tempfile.template = 'testcmd.' if os.name in ('posix', 'nt'): diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py index fce0fc8..fcd3e70 100644 --- a/QMTest/TestCommon.py +++ b/QMTest/TestCommon.py @@ -95,10 +95,13 @@ __version__ = "0.37" import copy import os -import os.path import stat import sys -import UserList +try: + from collections import UserList +except ImportError: + # no 'collections' module or no UserList in collections + exec('from UserList import UserList') from TestCmd import * from TestCmd import __all__ @@ -171,8 +174,7 @@ else: dll_suffix = '.so' def is_List(e): - return isinstance(e, list) \ - or isinstance(e, UserList.UserList) + return isinstance(e, (list,UserList)) def is_writable(f): mode = os.stat(f)[stat.ST_MODE] |