- Make a test in Py3k actually use StringMixIn instead of str. - Minor cosmetic fix.tags/v0.2
@@ -293,7 +293,7 @@ class Template(Node): | |||||
""" | """ | ||||
name = name.strip() if isinstance(name, basestring) else str(name) | name = name.strip() if isinstance(name, basestring) else str(name) | ||||
removed = False | removed = False | ||||
to_remove =[] | |||||
to_remove = [] | |||||
for i, param in enumerate(self.params): | for i, param in enumerate(self.params): | ||||
if param.name.strip() == name: | if param.name.strip() == name: | ||||
if keep_field: | if keep_field: | ||||
@@ -253,12 +253,12 @@ class StringMixIn(object): | |||||
if py3k: | if py3k: | ||||
@staticmethod | @staticmethod | ||||
@inheritdoc | @inheritdoc | ||||
def maketrans(self, x, y=None, z=None): | |||||
def maketrans(x, y=None, z=None): | |||||
if z is None: | if z is None: | ||||
if y is None: | if y is None: | ||||
return self.__unicode__.maketrans(x) | |||||
return self.__unicode__.maketrans(x, y) | |||||
return self.__unicode__.maketrans(x, y, z) | |||||
return str.maketrans(x) | |||||
return str.maketrans(x, y) | |||||
return str.maketrans(x, y, z) | |||||
@inheritdoc | @inheritdoc | ||||
def partition(self, sep): | def partition(self, sep): | ||||
@@ -414,10 +414,10 @@ class TestStringMixIn(unittest.TestCase): | |||||
self.assertEqual("Fake String", str1.title()) | self.assertEqual("Fake String", str1.title()) | ||||
if py3k: | if py3k: | ||||
table1 = str.maketrans({97: "1", 101: "2", 105: "3", 111: "4", | |||||
117: "5"}) | |||||
table2 = str.maketrans("aeiou", "12345") | |||||
table3 = str.maketrans("aeiou", "12345", "rts") | |||||
table1 = StringMixIn.maketrans({97: "1", 101: "2", 105: "3", | |||||
111: "4", 117: "5"}) | |||||
table2 = StringMixIn.maketrans("aeiou", "12345") | |||||
table3 = StringMixIn.maketrans("aeiou", "12345", "rts") | |||||
self.assertEqual("f1k2 str3ng", str1.translate(table1)) | self.assertEqual("f1k2 str3ng", str1.translate(table1)) | ||||
self.assertEqual("f1k2 str3ng", str1.translate(table2)) | self.assertEqual("f1k2 str3ng", str1.translate(table2)) | ||||
self.assertEqual("f1k2 3ng", str1.translate(table3)) | self.assertEqual("f1k2 3ng", str1.translate(table3)) | ||||