Merged revisions 2136-2200,2202-2290,2292-2301 via svnmerge from
[scons.git] / src / engine / SCons / UtilTests.py
index 724c51db241cc26ffb523fce9e86d5c36d3702b5..1149f35839a09d7450ae64ee782645a0207a93f4 100644 (file)
@@ -56,6 +56,7 @@ class UtilTestCase(unittest.TestCase):
         def __init__(self, name, children=[]):
             self.children = children
             self.name = name
+            self.nocache = None
         def __str__(self):
             return self.name
         def exists(self):
@@ -74,6 +75,8 @@ class UtilTestCase(unittest.TestCase):
             return 1
         def current(self):
             return 1
+        def noclean(self):
+            return 1
 
     def tree_case_1(self):
         """Fixture for the render_tree() and print_tree() tests."""
@@ -98,12 +101,12 @@ class UtilTestCase(unittest.TestCase):
 """
 
         lines = string.split(expect, '\n')[:-1]
-        lines = map(lambda l: '[E BSPAC]'+l, lines)
+        lines = map(lambda l: '[E BSPAC]'+l, lines)
         withtags = string.join(lines, '\n') + '\n'
 
         return foo, expect, withtags
 
-    def tree_case_2(self):
+    def tree_case_2(self, prune=1):
         """Fixture for the render_tree() and print_tree() tests."""
 
         stdlib_h = self.Node("stdlib.h")
@@ -118,10 +121,15 @@ class UtilTestCase(unittest.TestCase):
     +-blat.h
     | +-stdlib.h
     +-bar.h
+      +-[stdlib.h]
 """
 
+        if not prune:
+            expect = string.replace(expect, '[', '')
+            expect = string.replace(expect, ']', '')
+
         lines = string.split(expect, '\n')[:-1]
-        lines = map(lambda l: '[E BSPAC]'+l, lines)
+        lines = map(lambda l: '[E BSPAC]'+l, lines)
         withtags = string.join(lines, '\n') + '\n'
 
         return blat_o, expect, withtags
@@ -159,7 +167,7 @@ class UtilTestCase(unittest.TestCase):
             actual = sys.stdout.getvalue()
             assert withtags == actual, (withtags, actual)
 
-            node, expect, withtags = self.tree_case_2()
+            node, expect, withtags = self.tree_case_2(prune=0)
 
             sys.stdout = StringIO.StringIO()
             print_tree(node, get_children, 1)
@@ -186,6 +194,7 @@ class UtilTestCase(unittest.TestCase):
         assert is_Dict({})
         assert is_Dict(UserDict())
         assert not is_Dict([])
+        assert not is_Dict(())
         assert not is_Dict("")
         if hasattr(types, 'UnicodeType'):
             exec "assert not is_Dict(u'')"
@@ -194,6 +203,7 @@ class UtilTestCase(unittest.TestCase):
         assert is_List([])
         import UserList
         assert is_List(UserList.UserList())
+        assert not is_List(())
         assert not is_List({})
         assert not is_List("")
         if hasattr(types, 'UnicodeType'):
@@ -211,6 +221,15 @@ class UtilTestCase(unittest.TestCase):
             assert is_String(UserString.UserString(''))
         assert not is_String({})
         assert not is_String([])
+        assert not is_String(())
+
+    def test_is_Tuple(self):
+        assert is_Tuple(())
+        assert not is_Tuple([])
+        assert not is_Tuple({})
+        assert not is_Tuple("")
+        if hasattr(types, 'UnicodeType'):
+            exec "assert not is_Tuple(u'')"
 
     def test_to_String(self):
         """Test the to_String() method."""