Ignore:
Timestamp:
Jan 2, 2016, 6:25:14 PM (4 years ago)
Author:
cito
Message:

Amend tests so that they can run with PostgreSQL < 9.0

Note that we do not need to make these amendments in the trunk,
because we assume PostgreSQL >= 9.0 for PyGreSQL version 5.0.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.x/module/tests/test_classic_connection.py

    r650 r690  
    8787            inserttable locreate loimport parameter putline query reset
    8888            set_notice_receiver source transaction'''.split()
     89        if self.connection.server_version < 90000:  # PostgreSQL < 9.0
     90            methods.remove('escape_identifier')
     91            methods.remove('escape_literal')
    8992        connection_methods = [a for a in dir(self.connection)
    9093            if callable(eval("self.connection." + a))]
     
    559562        self.assertEqual(query("select 1, $1::integer", (2,)
    560563            ).getresult(), [(1, 2)])
    561         self.assertEqual(query("select 1 union select $1", (2,)
     564        self.assertEqual(query("select 1 union select $1::integer", (2,)
    562565            ).getresult(), [(1,), (2,)])
    563566        self.assertEqual(query("select $1::integer+$2", (1, 2)
     
    817820                if i < n:
    818821                    self.assertEqual(v, '%d\t%s' % data[i])
    819                 elif i == n:
     822                elif i == n or self.c.server_version < 90000:
    820823                    self.assertEqual(v, '\\.')
    821824                else:
     
    843846
    844847    def testGetNotify(self):
     848        if self.c.server_version < 90000:  # PostgreSQL < 9.0
     849            self.skipTest('Notify with payload not supported')
    845850        getnotify = self.c.getnotify
    846851        query = self.c.query
     
    859864            self.assertEqual(r[2], '')
    860865            self.assertIsNone(self.c.getnotify())
    861             try:
    862                 query("notify test_notify, 'test_payload'")
    863             except pg.ProgrammingError:  # PostgreSQL < 9.0
    864                 pass
    865             else:
    866                 r = getnotify()
    867                 self.assertTrue(isinstance(r, tuple))
    868                 self.assertEqual(len(r), 3)
    869                 self.assertIsInstance(r[0], str)
    870                 self.assertIsInstance(r[1], int)
    871                 self.assertIsInstance(r[2], str)
    872                 self.assertEqual(r[0], 'test_notify')
    873                 self.assertEqual(r[2], 'test_payload')
    874                 self.assertIsNone(getnotify())
     866            query("notify test_notify, 'test_payload'")
     867            r = getnotify()
     868            self.assertTrue(isinstance(r, tuple))
     869            self.assertEqual(len(r), 3)
     870            self.assertIsInstance(r[0], str)
     871            self.assertIsInstance(r[1], int)
     872            self.assertIsInstance(r[2], str)
     873            self.assertEqual(r[0], 'test_notify')
     874            self.assertEqual(r[2], 'test_payload')
     875            self.assertIsNone(getnotify())
    875876        finally:
    876877            query('unlisten test_notify')
     
    984985        de_locales = 'de', 'de_DE', 'de_DE.utf8', 'de_DE.UTF-8'
    985986        de_money = ('34,25€', '34,25 €', '€34,25' '€ 34,25',
    986             '34,25 EUR', '34,25 Euro', '34,25 DM')
     987            'EUR34,25', 'EUR 34,25', '34,25 EUR', '34,25 Euro', '34,25 DM')
    987988        # first try with English localization (using the point)
    988989        for lc in en_locales:
Note: See TracChangeset for help on using the changeset viewer.