def test_transliterate(): Assert(transliterate(u'äöü', 'one')) == u'aou' tests = zip([ (u'©', 'long'), (u'©', 'short'), (u'☺', 'one'), ], [u''] * 3 if translitcodec is None else [u'(c)', u'c', u'?']) for args, result in tests: Assert(transliterate(*args)) == result
def test_transliterate(): Assert(transliterate(u'äöü', 'one')) == u'aou' tests = zip( [ (u'©', 'long'), (u'©', 'short'), (u'☺', 'one'), ], [u''] * 3 if translitcodec is None else [u'(c)', u'c', u'?'] ) for args, result in tests: Assert(transliterate(*args)) == result
def encode(self, string): try: return string.encode(self.encoding) except UnicodeError: return transliterate(string, length='one').encode('ascii')
def encode(self, string): try: return string.encode(self.encoding) except UnicodeError: return transliterate(string, length='one').encode('ascii')