ソースを参照

Fix StringMixIn.maketrans() on Py3k.

- Make a test in Py3k actually use StringMixIn instead of str.
- Minor cosmetic fix.
tags/v0.2
Ben Kurtovic 11年前
コミット
3fb8f3214c
3個のファイルの変更9行の追加9行の削除
  1. +1
    -1
      mwparserfromhell/nodes/template.py
  2. +4
    -4
      mwparserfromhell/string_mixin.py
  3. +4
    -4
      tests/test_string_mixin.py

+ 1
- 1
mwparserfromhell/nodes/template.py ファイルの表示

@@ -293,7 +293,7 @@ class Template(Node):
"""
name = name.strip() if isinstance(name, basestring) else str(name)
removed = False
to_remove =[]
to_remove = []
for i, param in enumerate(self.params):
if param.name.strip() == name:
if keep_field:


+ 4
- 4
mwparserfromhell/string_mixin.py ファイルの表示

@@ -253,12 +253,12 @@ class StringMixIn(object):
if py3k:
@staticmethod
@inheritdoc
def maketrans(self, x, y=None, z=None):
def maketrans(x, y=None, z=None):
if z 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
def partition(self, sep):


+ 4
- 4
tests/test_string_mixin.py ファイルの表示

@@ -414,10 +414,10 @@ class TestStringMixIn(unittest.TestCase):
self.assertEqual("Fake String", str1.title())

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(table2))
self.assertEqual("f1k2 3ng", str1.translate(table3))


読み込み中…
キャンセル
保存