예제 #1
0
 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'))
예제 #2
0
 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'))
예제 #3
0
    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)
예제 #4
0
 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'))
예제 #5
0
파일: test_smtp.py 프로젝트: Almad/twisted
    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)
예제 #6
0
파일: test_smtp.py 프로젝트: Almad/twisted
 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'))