diff options
author | Greg Noel <GregNoel@tigris.org> | 2010-03-27 07:39:52 (GMT) |
---|---|---|
committer | Greg Noel <GregNoel@tigris.org> | 2010-03-27 07:39:52 (GMT) |
commit | 59ed0a109bf5add2efcef459080837b11066c6fb (patch) | |
tree | fff879b4f9676a72e16c0f7b4dd969f050038b4f /src/engine/SCons/UtilTests.py | |
parent | 00a3188193ba1feef927cf18e7f5fc20ad71b848 (diff) | |
download | SCons-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 'src/engine/SCons/UtilTests.py')
-rw-r--r-- | src/engine/SCons/UtilTests.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index 670fc83..ad27127 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -27,7 +27,6 @@ import os import os.path import StringIO import sys -import types import unittest from UserDict import UserDict @@ -38,6 +37,10 @@ import SCons.Errors from SCons.Util import * +try: unicode +except NameError: HasUnicode = False +else: HasUnicode = True + class OutBuffer: def __init__(self): self.buffer = "" @@ -214,7 +217,7 @@ class UtilTestCase(unittest.TestCase): assert not is_Dict([]) assert not is_Dict(()) assert not is_Dict("") - if hasattr(types, 'UnicodeType'): + if HasUnicode: exec "assert not is_Dict(u'')" def test_is_List(self): @@ -231,12 +234,12 @@ class UtilTestCase(unittest.TestCase): assert not is_List(()) assert not is_List({}) assert not is_List("") - if hasattr(types, 'UnicodeType'): + if HasUnicode: exec "assert not is_List(u'')" def test_is_String(self): assert is_String("") - if hasattr(types, 'UnicodeType'): + if HasUnicode: exec "assert is_String(u'')" try: import UserString @@ -267,7 +270,7 @@ class UtilTestCase(unittest.TestCase): assert not is_Tuple([]) assert not is_Tuple({}) assert not is_Tuple("") - if hasattr(types, 'UnicodeType'): + if HasUnicode: exec "assert not is_Tuple(u'')" def test_to_String(self): @@ -289,19 +292,19 @@ class UtilTestCase(unittest.TestCase): assert to_String(s2) == s2, s2 assert to_String(s2) == 'foo', s2 - if hasattr(types, 'UnicodeType'): + if HasUnicode: s3=UserString.UserString(unicode('bar')) assert to_String(s3) == s3, s3 assert to_String(s3) == unicode('bar'), s3 - assert type(to_String(s3)) is types.UnicodeType, \ + assert isinstance(to_String(s3), unicode), \ type(to_String(s3)) except ImportError: pass - if hasattr(types, 'UnicodeType'): + if HasUnicode: s4 = unicode('baz') assert to_String(s4) == unicode('baz'), to_String(s4) - assert type(to_String(s4)) is types.UnicodeType, \ + assert isinstance(to_String(s4), unicode), \ type(to_String(s4)) def test_WhereIs(self): |