Changeset 785


Ignore:
Timestamp:
Jan 26, 2016, 12:50:41 PM (4 years ago)
Author:
cito
Message:

Make all tests run again with Python 3

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/pg.py

    r781 r785  
    539539        """Prepare a bytea array parameter."""
    540540        if isinstance(d, list):
    541             return '{%s}' % ','.join(self._prepare_bytea_array(v) for v in d)
     541            return b'{' + b','.join(
     542                self._prepare_bytea_array(v) for v in d) + b'}'
    542543        if d is None:
    543             return 'null'
    544         return self.escape_bytea(d).replace('\\', '\\\\')
     544            return b'null'
     545        return self.escape_bytea(d).replace(b'\\', b'\\\\')
    545546
    546547    def _prepare_json_array(self, d):
  • trunk/pgmodule.c

    r784 r785  
    780780                                                get_decoded_string(estr, esize, encoding);
    781781                                        if (!element) /* no decoding necessary or possible */
    782 #else
     782#endif
    783783                                        element = PyBytes_FromStringAndSize(estr, esize);
    784 #endif
    785784                                        if (element && cast)
    786785                                        {
  • trunk/tests/test_classic_functions.py

    r781 r785  
    221221        self.assertEqual(f('{}'), [])
    222222        self.assertEqual(f('{}', None), [])
    223         self.assertEqual(f('{}', None, ';'), [])
     223        self.assertEqual(f('{}', None, b';'), [])
    224224        self.assertEqual(f('{}', str), [])
    225         self.assertEqual(f('{}', str, ';'), [])
     225        self.assertEqual(f('{}', str, b';'), [])
    226226
    227227    def testParserSimple(self):
     
    293293        f = pg.cast_array
    294294        self.assertEqual(f('{1,2}'), ['1', '2'])
    295         self.assertEqual(f('{1,2}', delim=','), ['1', '2'])
     295        self.assertEqual(f('{1,2}', delim=b','), ['1', '2'])
    296296        self.assertEqual(f('{1;2}'), ['1;2'])
    297         self.assertEqual(f('{1;2}', delim=';'), ['1', '2'])
    298         self.assertEqual(f('{1,2}', delim=';'), ['1,2'])
     297        self.assertEqual(f('{1;2}', delim=b';'), ['1', '2'])
     298        self.assertEqual(f('{1,2}', delim=b';'), ['1,2'])
    299299
    300300    def testParserWithData(self):
     
    321321
    322322        def replace_comma(value):
    323             if isinstance(value, basestring):
     323            if isinstance(value, str):
    324324                return value.replace(',', ';')
    325325            elif isinstance(value, list):
     
    334334            else:
    335335                expected = replace_comma(expected)
    336                 self.assertEqual(f(expression, cast, ';'), expected)
     336                self.assertEqual(f(expression, cast, b';'), expected)
    337337
    338338
Note: See TracChangeset for help on using the changeset viewer.