Changeset 525


Ignore:
Timestamp:
Nov 8, 2015, 1:01:14 PM (4 years ago)
Author:
darcy
Message:

Current excepton handling so that it can run under Python 3.

Location:
trunk/module
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/module/TEST_PyGreSQL_classic.py

    r521 r525  
    148148        try:
    149149            db.query("INSERT INTO _test_schema VALUES (1234)")
    150         except DatabaseError, error:
     150        except DatabaseError as error:
    151151            # currently PyGreSQL does not support IntegrityError
    152152            self.assert_(isinstance(error, ProgrammingError))
     
    326326
    327327    if len(sys.argv) == 2 and sys.argv[1] == '-l':
    328         print '\n'.join(unittest.getTestCaseNames(UtilityTest, 'test_'))
     328        print('\n'.join(unittest.getTestCaseNames(UtilityTest, 'test_')))
    329329        sys.exit(1)
    330330
     
    333333            suite.addTest(UtilityTest(test_name))
    334334        except:
    335             print "\n ERROR: %s.\n" % sys.exc_value
     335            print("\n ERROR: %s.\n" % sys.exc_value)
    336336            sys.exit(1)
    337337
  • trunk/module/TEST_PyGreSQL_dbapi20.py

    r521 r525  
    104104        try:
    105105            cur.execute("select 1/0")
    106         except pgdb.DatabaseError, error:
     106        except pgdb.DatabaseError as error:
    107107            self.assert_(isinstance(error, pgdb.ProgrammingError))
    108108            # the SQLSTATE error code for division by zero is 22012
     
    212212                    cur.execute("insert into %s values (3)" % table)
    213213                    cur.execute("insert into %s values (4)" % table)
    214             except con.ProgrammingError, error:
     214            except con.ProgrammingError as error:
    215215                self.assertTrue('check' in str(error).lower())
    216216            with con:
     
    222222                    cur.execute("insert into %s values (8)" % table)
    223223                    raise ValueError('transaction should rollback')
    224             except ValueError, error:
     224            except ValueError as error:
    225225                self.assertEqual(str(error), 'transaction should rollback')
    226226            with con:
Note: See TracChangeset for help on using the changeset viewer.