def test_decodeWithErrors(self): """ Similar to L{test_encodeWithErrors}, but for C{str.decode}. """ bytes = 'Hello world' self.assertEqual(smtp.xtext_decode(bytes, 'strict'), (bytes.decode('xtext'), len(bytes))) self.assertEqual(bytes.decode('xtext', 'strict'), bytes.decode('xtext'))
def test_decodeWithErrors(self): """ Similar to L{test_encodeWithErrors}, but for C{str.decode}. """ bytes = 'Hello world' self.assertEqual( smtp.xtext_decode(bytes, 'strict'), (bytes.decode('xtext'), len(bytes))) self.assertEqual( bytes.decode('xtext', 'strict'), bytes.decode('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)
def test_decodeWithErrors(self): """ Similar to L{test_encodeWithErrors}, but for C{str.decode}. """ bytes = 'Hello world' self.assertEqual(smtp._slowXTextDecode(bytes, 'strict'), (bytes.decode('xtext'), len(bytes))) # This might be the same as _slowXTextDecode, but it might also be the # fast version instead. self.assertEqual(smtp.xtext_decode(bytes, 'strict'), (bytes.decode('xtext'), len(bytes))) self.assertEqual(bytes.decode('xtext', 'strict'), bytes.decode('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)
def test_decodeWithErrors(self): """ Similar to L{test_encodeWithErrors}, but for C{str.decode}. """ bytes = 'Hello world' self.assertEqual( smtp._slowXTextDecode(bytes, 'strict'), (bytes.decode('xtext'), len(bytes))) # This might be the same as _slowXTextDecode, but it might also be the # fast version instead. self.assertEqual( smtp.xtext_decode(bytes, 'strict'), (bytes.decode('xtext'), len(bytes))) self.assertEqual( bytes.decode('xtext', 'strict'), bytes.decode('xtext'))