diff options
-rw-r--r-- | markupsafe/__init__.py | 4 | ||||
-rw-r--r-- | markupsafe/_compat.py | 2 | ||||
-rw-r--r-- | markupsafe/tests.py | 9 |
3 files changed, 13 insertions, 2 deletions
diff --git a/markupsafe/__init__.py b/markupsafe/__init__.py index 25f00d3..5c5af40 100644 --- a/markupsafe/__init__.py +++ b/markupsafe/__init__.py @@ -10,7 +10,7 @@ """ import re from markupsafe._compat import text_type, string_types, int_types, \ - unichr, PY2 + unichr, iteritems, PY2 __all__ = ['Markup', 'soft_unicode', 'escape', 'escape_silent'] @@ -168,7 +168,7 @@ class Markup(text_type): orig = getattr(text_type, name) def func(self, *args, **kwargs): args = _escape_argspec(list(args), enumerate(args), self.escape) - #_escape_argspec(kwargs, kwargs.iteritems(), None) + _escape_argspec(kwargs, iteritems(kwargs), self.escape) return self.__class__(orig(self, *args, **kwargs)) func.__name__ = orig.__name__ func.__doc__ = orig.__doc__ diff --git a/markupsafe/_compat.py b/markupsafe/_compat.py index 29e4a3d..62e5632 100644 --- a/markupsafe/_compat.py +++ b/markupsafe/_compat.py @@ -17,8 +17,10 @@ if not PY2: string_types = (str,) unichr = chr int_types = (int,) + iteritems = lambda x: iter(x.items()) else: text_type = unicode string_types = (str, unicode) unichr = unichr int_types = (int, long) + iteritems = lambda x: x.iteritems() diff --git a/markupsafe/tests.py b/markupsafe/tests.py index b34cc6e..145fafb 100644 --- a/markupsafe/tests.py +++ b/markupsafe/tests.py @@ -65,6 +65,15 @@ class MarkupTestCase(unittest.TestCase): assert Markup("<em>Foo & Bar</em>").striptags() == "Foo & Bar" assert Markup("<test>").unescape() == "<test>" + def test_formatting(self): + for actual, expected in ( + (Markup('%i') % 3.14, '3'), + (Markup('%.2f') % 3.14159, '3.14'), + (Markup('%s %s %s') % ('<', 123, '>'), '< 123 >'), + (Markup('<em>{awesome}</em>').format(awesome='<awesome>'), + '<em><awesome></em>')): + assert actual == expected, "%r should be %r!" % (actual, expected) + def test_all_set(self): import markupsafe as markup for item in markup.__all__: |