make code C++ warning clean (again)
[libfirm] / scripts / jinja2 / tests.py
index d257eca..50510b0 100644 (file)
 import re
 from jinja2.runtime import Undefined
 
+try:
+    from collections import Mapping as MappingType
+except ImportError:
+    import UserDict
+    MappingType = (UserDict.UserDict, UserDict.DictMixin, dict)
+
 # nose, nothing here to test
 __test__ = False
 
@@ -83,6 +89,14 @@ def test_string(value):
     return isinstance(value, basestring)
 
 
+def test_mapping(value):
+    """Return true if the object is a mapping (dict etc.).
+
+    .. versionadded:: 2.6
+    """
+    return isinstance(value, MappingType)
+
+
 def test_number(value):
     """Return true if the variable is a number."""
     return isinstance(value, (int, long, float, complex))
@@ -137,6 +151,7 @@ TESTS = {
     'lower':            test_lower,
     'upper':            test_upper,
     'string':           test_string,
+    'mapping':          test_mapping,
     'number':           test_number,
     'sequence':         test_sequence,
     'iterable':         test_iterable,