Example #1
0
 def test_es(self):
     from _testcapi import getargs_es
     self.assertEqual(getargs_es('abc\xe9'), b'abc\xc3\xa9')
     self.assertEqual(getargs_es('abc\xe9', 'latin1'), b'abc\xe9')
     self.assertRaises(UnicodeEncodeError, getargs_es, 'abc\xe9', 'ascii')
     self.assertRaises(LookupError, getargs_es, 'abc\xe9', 'spam')
     self.assertRaises(TypeError, getargs_es, b'bytes', 'latin1')
     self.assertRaises(TypeError, getargs_es, bytearray(b'bytearray'), 'latin1')
     self.assertRaises(TypeError, getargs_es, memoryview(b'memoryview'), 'latin1')
     self.assertRaises(TypeError, getargs_es, None, 'latin1')
     self.assertRaises(TypeError, getargs_es, 'nul:\0', 'latin1')
 def test_es(self):
     from _testcapi import getargs_es
     self.assertEqual(getargs_es('abc\xe9'), b'abc\xc3\xa9')
     self.assertEqual(getargs_es('abc\xe9', 'latin1'), b'abc\xe9')
     self.assertRaises(UnicodeEncodeError, getargs_es, 'abc\xe9', 'ascii')
     self.assertRaises(LookupError, getargs_es, 'abc\xe9', 'spam')
     self.assertRaises(TypeError, getargs_es, b'bytes', 'latin1')
     self.assertRaises(TypeError, getargs_es, bytearray(b'bytearray'), 'latin1')
     self.assertRaises(TypeError, getargs_es, memoryview(b'memoryview'), 'latin1')
     self.assertRaises(TypeError, getargs_es, None, 'latin1')
     self.assertRaises(TypeError, getargs_es, 'nul:\0', 'latin1')
Example #3
0
    def test_es(self):
        from _testcapi import getargs_es

        self.assertEqual(getargs_es("abc\xe9"), b"abc\xc3\xa9")
        self.assertEqual(getargs_es("abc\xe9", "latin1"), b"abc\xe9")
        self.assertRaises(UnicodeEncodeError, getargs_es, "abc\xe9", "ascii")
        self.assertRaises(LookupError, getargs_es, "abc\xe9", "spam")
        self.assertRaises(TypeError, getargs_es, b"bytes", "latin1")
        self.assertRaises(TypeError, getargs_es, bytearray(b"bytearray"), "latin1")
        self.assertRaises(TypeError, getargs_es, memoryview(b"memoryview"), "latin1")
        self.assertRaises(TypeError, getargs_es, None, "latin1")
        self.assertRaises(TypeError, getargs_es, "nul:\0", "latin1")
Example #4
0
 def test_es(self):
     from _testcapi import getargs_es
     self.assertEqual(getargs_es('abc'), 'abc')
     self.assertEqual(getargs_es(u'abc'), 'abc')
     self.assertEqual(getargs_es('abc', 'ascii'), 'abc')
     self.assertEqual(getargs_es(u'abc\xe9', 'latin1'), 'abc\xe9')
     self.assertRaises(UnicodeEncodeError, getargs_es, u'abc\xe9', 'ascii')
     self.assertRaises(LookupError, getargs_es, u'abc', 'spam')
     self.assertRaises(TypeError, getargs_es, bytearray('bytearray'),
                       'latin1')
     self.assertRaises(TypeError, getargs_es, memoryview('memoryview'),
                       'latin1')
     with test_support.check_py3k_warnings():
         self.assertEqual(getargs_es(buffer('abc'), 'ascii'), 'abc')
         self.assertEqual(getargs_es(buffer(u'abc'), 'ascii'), 'abc')
     self.assertRaises(TypeError, getargs_es, None, 'latin1')
     self.assertRaises(TypeError, getargs_es, 'nul:\0', 'latin1')
     self.assertRaises(TypeError, getargs_es, u'nul:\0', 'latin1')
Example #5
0
 def test_es(self):
     from _testcapi import getargs_es
     self.assertEqual(getargs_es('abc'), 'abc')
     self.assertEqual(getargs_es(u'abc'), 'abc')
     self.assertEqual(getargs_es('abc', 'ascii'), 'abc')
     self.assertEqual(getargs_es(u'abc\xe9', 'latin1'), 'abc\xe9')
     self.assertRaises(UnicodeEncodeError, getargs_es, u'abc\xe9', 'ascii')
     self.assertRaises(LookupError, getargs_es, u'abc', 'spam')
     self.assertRaises(TypeError, getargs_es,
                       bytearray('bytearray'), 'latin1')
     self.assertRaises(TypeError, getargs_es,
                       memoryview('memoryview'), 'latin1')
     with test_support.check_py3k_warnings():
         self.assertEqual(getargs_es(buffer('abc'), 'ascii'), 'abc')
         self.assertEqual(getargs_es(buffer(u'abc'), 'ascii'), 'abc')
     self.assertRaises(TypeError, getargs_es, None, 'latin1')
     self.assertRaises(TypeError, getargs_es, 'nul:\0', 'latin1')
     self.assertRaises(TypeError, getargs_es, u'nul:\0', 'latin1')