Пример #1
0
def main( pytest_version ):
    os.environ['PYTEST_STATE'] = 'Active'
 
    parser = ModeAndOptionParser( usage = "%prog mode [options] target*",
                                  version = "%prog " + pytest_version()   )
    
    verb_levels = [l for l in logging._levelNames if isinstance(l, basestring)]
    parser.add_option( '-v', "--verbosity",
                       choices=verb_levels, default="INFO",
                       help="One of %s [defaults to INFO]"%','.join(verb_levels) )
    
    parser.add_option("--mail", default=None,
                      help='Not supported yet.')
    
    parser.add_option( '--traceback',
                       action="store_true",
                       help="This flag triggers routines to report the traceback of "
                       "PyTestUsageError or KeyboardInterrupt. By default, "
                       "only the test's name and message are reported.",
                       default = False )

    parser.add_option( '--debug',
                       default=False, action="store_true", 
                       help="--debug is equivalent to --traceback --verbosity DEBUG.")

    try:
        options, targets   = parser.parse_args()
        if options.debug:
            options.traceback = True
            options.verbosity = "DEBUG"
    except SystemExit, e:
        core.exitPyTest("USAGE ERROR")
Пример #2
0
def main(pytest_version):
    os.environ['PYTEST_STATE'] = 'Active'

    parser = ModeAndOptionParser(usage="%prog mode [options] target*",
                                 version="%prog " + pytest_version())

    verb_levels = [l for l in logging._levelNames if isinstance(l, basestring)]
    parser.add_option('-v',
                      "--verbosity",
                      choices=verb_levels,
                      default="INFO",
                      help="One of %s [defaults to INFO]" %
                      ','.join(verb_levels))

    parser.add_option("--mail", default=None, help='Not supported yet.')

    parser.add_option(
        '--traceback',
        action="store_true",
        help="This flag triggers routines to report the traceback of "
        "PyTestUsageError or KeyboardInterrupt. By default, "
        "only the test's name and message are reported.",
        default=False)

    parser.add_option(
        '--debug',
        default=False,
        action="store_true",
        help="--debug is equivalent to --traceback --verbosity DEBUG.")

    try:
        options, targets = parser.parse_args()
        if options.debug:
            options.traceback = True
            options.verbosity = "DEBUG"
    except SystemExit, e:
        core.exitPyTest("USAGE ERROR")
Пример #3
0
    newline = '\n  '
    logging.info( newline.join(
        [ "%sPyTest %s"%(newline,pytest_version()),
          "(c) 2004-2006, Christian Dorion",
          "This is free software distributed under a BSD type license.",
          "Report problems to [email protected]\n" ]) )
    
    try:
        parser.selected_mode( targets, options )    

    except KeyboardInterrupt, kex:
        if options.traceback:
            print core.traceback(kex)
        else:            
            logging.info("Interupted by user.")

    except core.PyTestUsageError, e: 
        core.updateExitCode("USAGE ERROR")
        if options.traceback:
            print core.traceback(e)
        else:
            logging.critical( "%s: %s." % (e.__class__.__name__,e) )

    except Exception, unexpected: 
        core.updateExitCode("INTERNAL ERROR")
        print core.traceback(unexpected)

    logging.debug("\nQuitting PyTest.")
    logging.info('')
    core.exitPyTest()
Пример #4
0
        newline.join([
            "%sPyTest %s" % (newline, pytest_version()),
            "(c) 2004-2006, Christian Dorion",
            "This is free software distributed under a BSD type license.",
            "Report problems to [email protected]\n"
        ]))

    try:
        parser.selected_mode(targets, options)

    except KeyboardInterrupt, kex:
        if options.traceback:
            print core.traceback(kex)
        else:
            logging.info("Interupted by user.")

    except core.PyTestUsageError, e:
        core.updateExitCode("USAGE ERROR")
        if options.traceback:
            print core.traceback(e)
        else:
            logging.critical("%s: %s." % (e.__class__.__name__, e))

    except Exception, unexpected:
        core.updateExitCode("INTERNAL ERROR")
        print core.traceback(unexpected)

    logging.debug("\nQuitting PyTest.")
    logging.info('')
    core.exitPyTest()