Changeset 615 for trunk


Ignore:
Timestamp:
Nov 23, 2015, 4:15:38 PM (4 years ago)
Author:
cito
Message:

Reset decimal point and class after testing

These were not always reset in the case of failures which then could
cause subsequent failures.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/module/TEST_PyGreSQL_classic_connection.py

    r613 r615  
    11421142        self.assertIsInstance(point, str)
    11431143        self.assertEqual(point, '.')
     1144        pg.set_decimal_point(',')
     1145        try:
     1146            r = pg.get_decimal_point()
     1147        finally:
     1148            pg.set_decimal_point(point)
     1149        self.assertIsInstance(r, str)
     1150        self.assertEqual(r, ',')
    11441151
    11451152    def testSetDecimalPoint(self):
     
    11601167        else:
    11611168            self.SkipTest("cannot set English money locale")
    1162         pg.set_decimal_point('.')
    11631169        try:
    11641170            r = query("select '34.25'::money")
     
    11671173            # converted using the encoding of the test database
    11681174            self.skipTest('database does not support money')
    1169         r = r.getresult()[0][0]
     1175        pg.set_decimal_point('.')
     1176        try:
     1177            r = r.getresult()[0][0]
     1178        finally:
     1179            pg.set_decimal_point(point)
    11701180        self.assertIsInstance(r, d)
    11711181        self.assertEqual(r, d('34.25'))
     1182        r = query("select '34.25'::money")
    11721183        pg.set_decimal_point(',')
    1173         r = query("select '34.25'::money").getresult()[0][0]
     1184        try:
     1185            r = r.getresult()[0][0]
     1186        finally:
     1187            pg.set_decimal_point(point)
    11741188        self.assertNotEqual(r, d('34.25'))
    11751189        # then try with German localization (using the comma)
     
    11831197        else:
    11841198            self.SkipTest("cannot set German money locale")
    1185         pg.set_decimal_point(',')
    11861199        try:
    11871200            r = query("select '34,25'::money")
    11881201        except pg.ProgrammingError:
    11891202            self.skipTest('database does not support money')
     1203        pg.set_decimal_point(',')
     1204        try:
     1205            r = r.getresult()[0][0]
     1206        finally:
     1207            pg.set_decimal_point(point)
     1208        self.assertIsInstance(r, d)
     1209        self.assertEqual(r, d('34.25'))
     1210        r = query("select '34,25'::money")
     1211        pg.set_decimal_point('.')
     1212        try:
     1213            r = r.getresult()[0][0]
     1214        finally:
     1215            pg.set_decimal_point(point)
     1216        self.assertNotEqual(r, d('34.25'))
     1217
     1218    def testSetDecimal(self):
     1219        d = pg.Decimal
     1220        query = self.c.query
     1221        try:
     1222            r = query("select 3425::numeric")
     1223        except pg.ProgrammingError:
     1224            self.skipTest('database does not support numeric')
    11901225        r = r.getresult()[0][0]
    11911226        self.assertIsInstance(r, d)
    1192         self.assertEqual(r, d('34.25'))
    1193         pg.set_decimal_point('.')
    1194         try:
    1195             r = query("select '34,25'::money")
    1196         except pg.ProgrammingError:
    1197             self.skipTest('database does not support money')
    1198         r = r.getresult()[0][0]
    1199         self.assertNotEqual(r, d('34.25'))
    1200         pg.set_decimal_point(point)
    1201 
    1202     def testSetDecimal(self):
    1203         d = pg.Decimal
    1204         query = self.c.query
    1205         r = query("select 3425::numeric").getresult()[0][0]
    1206         self.assertIsInstance(r, d)
    12071227        self.assertEqual(r, d('3425'))
     1228        r = query("select 3425::numeric")
    12081229        pg.set_decimal(long)
    1209         r = query("select 3425::numeric").getresult()[0][0]
     1230        try:
     1231            r = r.getresult()[0][0]
     1232        finally:
     1233            pg.set_decimal(d)
    12101234        self.assertNotIsInstance(r, d)
    12111235        self.assertIsInstance(r, long)
    12121236        self.assertEqual(r, long(3425))
    1213         pg.set_decimal(d)
    12141237
    12151238    def testSetNamedresult(self):
Note: See TracChangeset for help on using the changeset viewer.