summaryrefslogtreecommitdiff
path: root/src/engine/SCons/Scanner/ScannerTests.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/Scanner/ScannerTests.py')
-rw-r--r--src/engine/SCons/Scanner/ScannerTests.py46
1 files changed, 20 insertions, 26 deletions
diff --git a/src/engine/SCons/Scanner/ScannerTests.py b/src/engine/SCons/Scanner/ScannerTests.py
index 2a65b36..c70b8a6 100644
--- a/src/engine/SCons/Scanner/ScannerTests.py
+++ b/src/engine/SCons/Scanner/ScannerTests.py
@@ -19,23 +19,24 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-__revision__ = "src/engine/SCons/Scanner/ScannerTests.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Scanner/ScannerTests.py 5023 2010/06/14 22:05:46 scons"
+
+import SCons.compat
+import collections
import sys
import unittest
-import UserDict
import SCons.Scanner
-class DummyFS:
+class DummyFS(object):
def File(self, name):
return DummyNode(name)
-class DummyEnvironment(UserDict.UserDict):
+class DummyEnvironment(collections.UserDict):
def __init__(self, dict=None, **kw):
- UserDict.UserDict.__init__(self, dict)
+ collections.UserDict.__init__(self, dict)
self.data.update(kw)
self.fs = DummyFS()
def subst(self, strSubst, target=None, source=None, conv=None):
@@ -47,13 +48,13 @@ class DummyEnvironment(UserDict.UserDict):
return [self.data[strSubst[1:]]]
return [[strSubst]]
def subst_path(self, path, target=None, source=None, conv=None):
- if type(path) != type([]):
+ if not isinstance(path, list):
path = [path]
- return map(self.subst, path)
+ return list(map(self.subst, path))
def get_factory(self, factory):
return factory or self.fs.File
-class DummyNode:
+class DummyNode(object):
def __init__(self, name, search_result=()):
self.name = name
self.search_result = tuple(search_result)
@@ -105,7 +106,7 @@ class ScannerTestCase(unittest.TestCase):
class BaseTestCase(unittest.TestCase):
- class skey_node:
+ class skey_node(object):
def __init__(self, key):
self.key = key
def scanner_key(self):
@@ -127,13 +128,13 @@ class BaseTestCase(unittest.TestCase):
self.deps = deps
path = scanner.path(env)
scanned = scanner(filename, env, path)
- scanned_strs = map(lambda x: str(x), scanned)
+ scanned_strs = [str(x) for x in scanned]
self.failUnless(self.filename == filename, "the filename was passed incorrectly")
self.failUnless(self.env == env, "the environment was passed incorrectly")
self.failUnless(scanned_strs == deps, "the dependencies were returned incorrectly")
for d in scanned:
- self.failUnless(type(d) != type(""), "got a string in the dependencies")
+ self.failUnless(not isinstance(d, str), "got a string in the dependencies")
if len(args) > 0:
self.failUnless(self.arg == args[0], "the argument was passed incorrectly")
@@ -241,7 +242,7 @@ class BaseTestCase(unittest.TestCase):
dict = {}
dict[s] = 777
i = hash(id(s))
- h = hash(dict.keys()[0])
+ h = hash(list(dict.keys())[0])
self.failUnless(h == i,
"hash Scanner base class expected %s, got %s" % (i, h))
@@ -280,7 +281,7 @@ class BaseTestCase(unittest.TestCase):
"recursive = 1 didn't return all nodes: %s" % n)
def odd_only(nodes):
- return filter(lambda n: n % 2, nodes)
+ return [n for n in nodes if n % 2]
s = SCons.Scanner.Base(function = self.func, recursive = odd_only)
n = s.recurse_nodes(nodes)
self.failUnless(n == [1, 3],
@@ -337,7 +338,7 @@ class BaseTestCase(unittest.TestCase):
assert s == 'xyzzy', s
class SelectorTestCase(unittest.TestCase):
- class skey_node:
+ class skey_node(object):
def __init__(self, key):
self.key = key
def scanner_key(self):
@@ -396,7 +397,7 @@ class SelectorTestCase(unittest.TestCase):
class CurrentTestCase(unittest.TestCase):
def test_class(self):
"""Test the Scanner.Current class"""
- class MyNode:
+ class MyNode(object):
def __init__(self):
self.called_has_builder = None
self.called_is_up_to_date = None
@@ -470,7 +471,7 @@ class ClassicTestCase(unittest.TestCase):
def test_scan(self):
"""Test the Scanner.Classic scan() method"""
- class MyNode:
+ class MyNode(object):
def __init__(self, name):
self.name = name
self._rfile = self
@@ -568,14 +569,7 @@ class ClassicCPPTestCase(unittest.TestCase):
assert n == 'path/bbb', n
assert i == 'bbb', i
- # TODO(1.5): remove when 2.2 is minimal; replace ccc
- # variable in find_include() call below with in-line u'ccc'.
- try:
- ccc = eval("u'ccc'")
- except SyntaxError:
- ccc = 'ccc'
-
- n, i = s.find_include(('<', ccc), 'foo', ('path',))
+ n, i = s.find_include(('<', u'ccc'), 'foo', ('path',))
assert n == 'path/ccc', n
assert i == 'ccc', i
@@ -595,7 +589,7 @@ def suite():
]
for tclass in tclasses:
names = unittest.getTestCaseNames(tclass, 'test_')
- suite.addTests(map(tclass, names))
+ suite.addTests(list(map(tclass, names)))
return suite
if __name__ == "__main__":