Changeset 592


Ignore:
Timestamp:
Nov 22, 2015, 6:13:46 AM (4 years ago)
Author:
cito
Message:

Adapt some more tests for Python 3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/module/TEST_PyGreSQL_classic_dbwrapper.py

    r591 r592  
    329329        # note that escape_byte always returns hex output since Pg 9.0,
    330330        # regardless of the bytea_output setting
    331         self.assertEqual(f("plain"), r"\x706c61696e")
    332         self.assertEqual(f("that's k\xe4se"), r"\x746861742773206be47365")
    333         self.assertEqual(f('O\x00ps\xff!'), r"\x4f007073ff21")
     331        r = f(b'plain')
     332        self.assertIsInstance(r, str)
     333        self.assertEqual(r, r'\x706c61696e')
     334        r = f(u'plain')
     335        self.assertIsInstance(r, str)
     336        self.assertEqual(r, r'\x706c61696e')
     337        r = f(u"das is' kÀse".encode('utf-8'))
     338        self.assertIsInstance(r, str)
     339        self.assertEqual(r, r'\x64617320697327206bc3a47365')
     340        r = f("das is' kÀse")
     341        self.assertIsInstance(r, str)
     342        self.assertEqual(r, r'\x64617320697327206bc3a47365')
     343        self.assertEqual(f(b'O\x00ps\xff!'), r'\x4f007073ff21')
    334344
    335345    def testUnescapeBytea(self):
    336346        f = self.db.unescape_bytea
    337         self.assertEqual(f("plain"), "plain")
    338         self.assertEqual(f("that's k\\344se"), "that's k\xe4se")
    339         self.assertEqual(f(r'O\000ps\377!'), 'O\x00ps\xff!')
    340         self.assertEqual(f(r"\\x706c61696e"), r"\x706c61696e")
    341         self.assertEqual(f(r"\\x746861742773206be47365"),
    342             r"\x746861742773206be47365")
    343         self.assertEqual(f(r"\\x4f007073ff21"), r"\x4f007073ff21")
     347        r = f(b'plain')
     348        self.assertIsInstance(r, str)
     349        self.assertEqual(r, 'plain')
     350        r = f(u'plain')
     351        self.assertIsInstance(r, str)
     352        self.assertEqual(r, 'plain')
     353        r = f(b"das is' k\\303\\244se")
     354        self.assertIsInstance(r, str)
     355        self.assertEqual(r, "das is' kÀse")
     356        r = f(u"das is' k\\303\\244se")
     357        self.assertIsInstance(r, str)
     358        self.assertEqual(r, "das is' kÀse")
     359        self.assertEqual(f(r'O\\000ps\\377!'), r'O\000ps\377!')
     360        self.assertEqual(f(r'\\x706c61696e'), r'\x706c61696e')
     361        self.assertEqual(f(r'\\x746861742773206be47365'),
     362            r'\x746861742773206be47365')
     363        self.assertEqual(f(r'\\x4f007073ff21'), r'\x4f007073ff21')
    344364
    345365    def testQuote(self):
Note: See TracChangeset for help on using the changeset viewer.