Ejemplo n.º 1
0
 def __call__(self, argv):
     cf = self.reporter.config
     cf.flags.DEBUG = 0
     cf.flags.VERBOSE = 0
     optlist, extraopts, args = getopt.getopt(argv[1:], "h?gdDvc:f:")
     for opt, optarg in optlist:
         if opt in ("-h", "-?"):
             print(TestReporterInterfaceDoc % (os.path.basename(argv[0]), ))
             return
         elif opt == "-g":
             self.reporter.report_global()
         elif opt == "-d":
             cf.flags.DEBUG += 1
         elif opt == "-D":
             from pycopia import autodebug  # top-level debug for framework bugs
         elif opt == "-v":
             cf.flags.VERBOSE += 1
         elif opt == "-c" or opt == "-f":
             cf.mergefile(optarg)
     cf.evalupdate(extraopts)
     if not args:
         args = choose_tests()
     if not args:
         return
     objects, errors = module.get_objects(args)
     if errors:
         self.reporter.report_errors(errors)
     if objects:
         self.reporter.report_objects(objects)
Ejemplo n.º 2
0
 def __call__(self, argv):
     cf = self.reporter.config
     cf.flags.DEBUG = 0
     cf.flags.VERBOSE = 0
     optlist, extraopts, args = getopt.getopt(argv[1:], "h?gdDvc:f:")
     for opt, optarg in optlist:
         if opt in ("-h", "-?"):
             print (TestReporterInterfaceDoc % (os.path.basename(argv[0]),))
             return
         elif opt == "-g":
             self.reporter.report_global()
         elif opt == "-d":
             cf.flags.DEBUG += 1
         elif opt == "-D":
             from pycopia import autodebug # top-level debug for framework bugs
         elif opt == "-v":
             cf.flags.VERBOSE += 1
         elif opt == "-c" or opt == "-f":
             cf.mergefile(optarg)
     cf.evalupdate(extraopts)
     if not args:
         args = choose_tests()
     if not args:
         return
     objects, errors = module.get_objects(args)
     if errors:
         self.reporter.report_errors(errors)
     if objects:
         self.reporter.report_objects(objects)
Ejemplo n.º 3
0
    def __call__(self, argv):
        """Run the test runner.

        Invoke the test runner by calling it.
        """
        cf = self.runner.config
        cf.flags.REPORT = False
        cf.flags.INTERACTIVE = False
        cf.flags.DEBUG = 0
        cf.flags.VERBOSE = 0
        optlist, extraopts, args = getopt.getopt(argv[1:], "h?dDviIrc:f:n:")
        for opt, optarg in optlist:
            if opt in ("-h", "-?"):
                print (TestRunnerInterfaceDoc % (os.path.basename(argv[0]),))
                return
            elif opt == "-d":
                cf.flags.DEBUG += 1
            elif opt == "-D":
                from pycopia import autodebug # top-level debug for framework bugs
            elif opt == "-v":
                cf.flags.VERBOSE += 1
            elif opt == "-i":
                cf.flags.INTERACTIVE = True
            elif opt == "-I":
                cf.flags.INTERACTIVE = False
            elif opt == "-c" or opt == "-f":
                cf.mergefile(optarg)
            elif opt == "-n":
                cf.comment = optarg
            elif opt == "-r":
                cf.flags.REPORT = True
        cf.evalupdate(extraopts)
        # original command line arguments saved for the report
        cf.arguments = [os.path.basename(argv[0])] + argv[1:]
        # Save extra options for overriding configuration after a mergefile
        # because command line options should have highest precedence.
        self.runner.set_options(extraopts)

        if not args:
            if cf.flags.REPORT:
                self.runner.report_global()
                return 0
            else:
                args = choose_tests()
        if not args:
            return 2
        objects, errors = module.get_objects(args)
        if errors:
            logging.warn("Errors found while loading test object:")
            for error in errors:
                logging.warn(error)
        if objects:
            cf.argv = args
            self.runner.initialize()
            rv = self.runner.run_objects(objects)
            self.runner.finalize()
            return not rv # inverted due to shell semantics (zero is good) being different from result code
        else:
            return int(bool(errors)) + 2
Ejemplo n.º 4
0
    def __call__(self, argv):
        """Run the test runner.

        Invoke the test runner by calling it.
        """
        cf = self.runner.config
        cf.flags.REPORT = False
        cf.flags.INTERACTIVE = False
        cf.flags.DEBUG = 0
        cf.flags.VERBOSE = 0
        optlist, extraopts, args = getopt.getopt(argv[1:], "h?dDviIrc:f:n:")
        for opt, optarg in optlist:
            if opt in ("-h", "-?"):
                print(TestRunnerInterfaceDoc % (os.path.basename(argv[0]), ))
                return
            elif opt == "-d":
                cf.flags.DEBUG += 1
            elif opt == "-D":
                from pycopia import autodebug  # top-level debug for framework bugs
            elif opt == "-v":
                cf.flags.VERBOSE += 1
            elif opt == "-i":
                cf.flags.INTERACTIVE = True
            elif opt == "-I":
                cf.flags.INTERACTIVE = False
            elif opt == "-c" or opt == "-f":
                cf.mergefile(optarg)
            elif opt == "-n":
                cf.comment = optarg
            elif opt == "-r":
                cf.flags.REPORT = True
        cf.evalupdate(extraopts)
        # original command line arguments saved for the report
        cf.arguments = [os.path.basename(argv[0])] + argv[1:]
        # Save extra options for overriding configuration after a mergefile
        # because command line options should have highest precedence.
        self.runner.set_options(extraopts)

        if not args:
            if cf.flags.REPORT:
                self.runner.report_global()
                return 0
            else:
                args = choose_tests()
        if not args:
            return 2
        objects, errors = module.get_objects(args)
        if errors:
            logging.warn("Errors found while loading test object:")
            for error in errors:
                logging.warn(error)
        if objects:
            cf.argv = args
            self.runner.initialize()
            rv = self.runner.run_objects(objects)
            self.runner.finalize()
            return not rv  # inverted due to shell semantics (zero is good) being different from result code
        else:
            return int(bool(errors)) + 2
Ejemplo n.º 5
0
    def run(self, argv):
        """Run the test runner.

        Invoke the test runner by calling it.
        """
        cf = self.runner.config
        cf.flags.INTERACTIVE = True
        cf.flags.DEBUG = 0
        cf.flags.VERBOSE = 0
        optlist, longopts, args = getopt.getopt(argv[1:], "h?dDvIc:f:m:e:r:")
        for opt, optarg in optlist:
            if opt in ("-h", "-?"):
                print(TestRunnerInterfaceDoc.format(
                    name=os.path.basename(argv[0])))
                return
            elif opt == "-d":
                cf.flags.DEBUG += 1
            elif opt == "-D":
                from pycopia import autodebug  # noqa
            elif opt == "-v":
                cf.flags.VERBOSE += 1
            elif opt == "-I":
                cf.flags.INTERACTIVE = False
            elif opt == "-c" or opt == "-f":
                cf.mergefile(optarg)
            elif opt == "-m":
                cf.comment = optarg
            elif opt == "-r":
                cf.reportname = optarg
            elif opt == "-e":
                cf.environmentname = optarg

        cf.evalupdate(longopts)
        # original command line arguments saved for the report
        cf.arguments = [os.path.basename(argv[0])] + argv[1:]

        ui = UI.get_userinterface(themename="ANSITheme")
        if not args:
            from . import simplechooser
            args = simplechooser.choose_tests(ui)
        if not args:
            return 10
        objects, errors = module.get_objects(args)
        if errors:
            logging.warn("Errors found while loading test object:")
            for error in errors:
                logging.warn(error)
        if objects:
            cf.argv = args
            rv = self.runner.run(objects, ui)
            if rv is None:
                return 11
            else:
                try:
                    return int(rv)
                except TypeError:
                    return 12
        else:
            return len(errors) + 20
Ejemplo n.º 6
0
def unittest(argv):
    args = argv[1:]
    _init_db()
    tr = testrunner.TestRunner("sqlite://:memory:")
    ui = UI.get_userinterface(themename="ANSITheme")
    if not args:
        args = all_tests(ui)
        for tn in args:
            print(tn)
        return
    if not args:
        return
    objects, errors = module.get_objects(args)
    if errors:
        print("Errors found while loading test object:")
        for error in errors:
            print(error)
    if objects:
        tr.run(objects, ui)
Ejemplo n.º 7
0
def unittest(argv):
    args = argv[1:]
    _init_db()
    tr = testrunner.TestRunner("sqlite://:memory:")
    ui = UI.get_userinterface(themename="ANSITheme")
    if not args:
        args = all_tests(ui)
        for tn in args:
            print(tn)
        return
    if not args:
        return
    objects, errors = module.get_objects(args)
    if errors:
        print("Errors found while loading test object:")
        for error in errors:
            print(error)
    if objects:
        tr.run(objects, ui)