Changeset 806 for trunk/tests


Ignore:
Timestamp:
Feb 1, 2016, 1:38:05 AM (3 years ago)
Author:
cito
Message:

Return bools from Postgres as Python bools by default

This has been done by the DB-API 2 module already and was configurable
in the classic module since a long time, but by default it was disabled.
It is now time to flip the switch and have this activated by default in
version 5.0. You can still restore the old behavior with set_bool(False).

Location:
trunk/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/test_classic_connection.py

    r801 r806  
    753753            ).getresult(), [(None,)])
    754754
    755     def testQueryWithBoolParams(self, use_bool=None):
     755    def testQueryWithBoolParams(self, bool_enabled=None):
    756756        query = self.c.query
    757         if use_bool is not None:
    758             use_bool_default = pg.get_bool()
    759             pg.set_bool(use_bool)
    760         try:
    761             v_false, v_true = (False, True) if use_bool else 'ft'
     757        if bool_enabled is not None:
     758            bool_enabled_default = pg.get_bool()
     759            pg.set_bool(bool_enabled)
     760        try:
     761            v_false, v_true = (False, True) if bool_enabled else 'ft'
    762762            r_false, r_true = [(v_false,)], [(v_true,)]
    763763            self.assertEqual(query("select false").getresult(), r_false)
     
    776776            self.assertEqual(query(q, (True,)).getresult(), r_true)
    777777        finally:
    778             if use_bool is not None:
    779                 pg.set_bool(use_bool_default)
    780 
    781     def testQueryWithBoolParamsAndUseBool(self):
    782         self.testQueryWithBoolParams(use_bool=True)
     778            if bool_enabled is not None:
     779                pg.set_bool(bool_enabled_default)
     780
     781    def testQueryWithBoolParamsNotDefault(self):
     782        self.testQueryWithBoolParams(bool_enabled=not pg.get_bool())
    783783
    784784    def testQueryWithIntParams(self):
  • trunk/tests/test_classic_functions.py

    r802 r806  
    713713        r = pg.get_bool()
    714714        self.assertIsInstance(r, bool)
    715         self.assertIs(r, False)
     715        self.assertIs(r, True)
    716716
    717717    def testSetBool(self):
    718718        use_bool = pg.get_bool()
    719719        try:
    720             pg.set_bool(True)
     720            pg.set_bool(False)
    721721            r = pg.get_bool()
    722722            pg.set_bool(use_bool)
    723723            self.assertIsInstance(r, bool)
    724             self.assertIs(r, True)
    725             pg.set_bool(False)
     724            self.assertIs(r, False)
     725            pg.set_bool(True)
    726726            r = pg.get_bool()
    727727            self.assertIsInstance(r, bool)
    728             self.assertIs(r, False)
     728            self.assertIs(r, True)
    729729        finally:
    730730            pg.set_bool(use_bool)
Note: See TracChangeset for help on using the changeset viewer.