def test_encodeWithErrors(self): """ Specifying an error policy to C{unicode.encode} with the I{xtext} codec should produce the same result as not specifying the error policy. """ text = u'Hello world' self.assertEqual(smtp.xtext_encode(text, 'strict'), (text.encode('xtext'), len(text))) self.assertEqual(text.encode('xtext', 'strict'), text.encode('xtext'))
def test_encodeWithErrors(self): """ Specifying an error policy to C{unicode.encode} with the I{xtext} codec should produce the same result as not specifying the error policy. """ text = u'Hello world' self.assertEqual( smtp.xtext_encode(text, 'strict'), (text.encode('xtext'), len(text))) self.assertEqual( text.encode('xtext', 'strict'), text.encode('xtext'))
def testXtextEncoding(self): cases = [ ('Hello world', 'Hello+20world'), ('Hello+world', 'Hello+2Bworld'), ('\0\1\2\3\4\5', '+00+01+02+03+04+05'), ('[email protected]', '*****@*****.**') ] for (case, expected) in cases: self.assertEqual(smtp.xtext_encode(case), (expected, len(case))) self.assertEquals(case.encode('xtext'), expected) self.assertEqual( smtp.xtext_decode(expected), (case, len(expected))) self.assertEquals(expected.decode('xtext'), case)