Changeset 537 for branches/4.x


Ignore:
Timestamp:
Nov 17, 2015, 4:16:21 PM (4 years ago)
Author:
cito
Message:

Let test take options and return an exit code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.x/module/test_pg.py

    r521 r537  
    3131
    3232import pg
     33
     34import sys
    3335import unittest
    3436import locale
     
    470472        self.c.query(q)
    471473
    472     def testSelectSemicolon(self):
    473         q = "select ;"
     474    def testSelectDotSemicolon(self):
     475        q = "select .;"
    474476        self.assertRaises(pg.ProgrammingError, self.c.query, q)
    475477
     
    643645    def testPrint(self):
    644646        import os
    645         import sys
    646647        q = ("select 1 as a, 'hello' as h, 'w' as world"
    647648            " union select 2, 'xyz', 'uvw'")
     
    21002101    ))
    21012102
    2102     unittest.TextTestRunner(verbosity=2).run(TestSuite)
     2103    opts = dict(verbosity=1)
     2104    if '-v' in sys.argv:
     2105        opts.update(verbosity=2)
     2106    if '-f' in sys.argv:
     2107        opts.update(failfast=True)  # needs Python 2.7
     2108
     2109    rc = unittest.TextTestRunner(**opts).run(TestSuite)
     2110
     2111    sys.exit(1 if rc.errors or rc.failures else 0)
Note: See TracChangeset for help on using the changeset viewer.