def main():
    if len(sys.argv) > 1 and sys.argv[1] == "--debug":
        del sys.argv[1]
        logging.basicConfig(level=logging.DEBUG)
    else:
        logging.basicConfig(level=logging.INFO)
    unittest.main()
Beispiel #2
1
def main():
    global DELETE, OUTPUT
    parser = OptionParser()
    parser.add_option("--list", action="store", dest="listTests")
    parser.add_option("--nodelete", action="store_true")
    parser.add_option("--output", action="store_true")
    # The following options are passed to unittest.
    parser.add_option("-e", "--explain", action="store_true")
    parser.add_option("-v", "--verbose", action="store_true")
    parser.add_option("-q", "--quiet", action="store_true")
    opts, files = parser.parse_args()
    if opts.nodelete:
        DELETE = False
    if opts.output:
        OUTPUT = True
    if opts.listTests:
        listTests(opts.listTests)
    else:
        # Eliminate script-specific command-line arguments to prevent
        # errors in unittest.
        del sys.argv[1:]
        for opt in ("explain", "verbose", "quiet"):
            if getattr(opts, opt):
                sys.argv.append("--" + opt)
        sys.argv.extend(files)
        unittest.main()
def test_main():
    try:
        from test import test_support

        test_support.run_unittest(test_ComException)
    except ImportError:
        unittest.main()
def main(argv):
    if len(argv) != 2 or argv[1] in ["-h", "-help", "--help", "help"]:
        usage = """
              Usage: %s CvsRoot|test (use test to run selftest)
        
              Change the CVS/Root files under the current CVS working directory
              to point to the CvsRoot value provided.
              
              so if you:
              bash$ cvs -d /oldrepo co stuff
              bash$ mv /oldrepo /newrepo
              bash$ cd stuff
              bash$ %s /newrepo
              bash$ cvs log # will work again.
              
              Useful if you have to move your cvs repository when you have 
              items checked out.
              """ % (
            argv[0],
            argv[0],
        )

        print textwrap.dedent(usage)
        print "Command: " + ", ".join(argv)
        sys.exit(2)

    newRepos = sys.argv.pop()

    if newRepos == "test":
        unittest.main()
    else:
        change_cvs_root(newRepos)
        print "Changed CVS/Root files to point to", newRepos
        sys.exit(0)
Beispiel #5
1
def main():
    """Runs the testsuite as command line application.
    """
    try:
        unittest.main()
    except Exception as e:
        print("Error: %s" % e)
 def main():
     # sys.path.insert(0, "C:/Program Files/Southpaw/Tactic1.9/src/client")
     sys.path.insert(0, "..")
     try:
         unittest.main()
     except SystemExit:
         pass
Beispiel #7
0
    def main():
        "main is the traditional module entrypoint"

        # Convert command-line arguments to a dictionary suitable for members.
        kwargs = {k.strip("-"): w for k, w in docopt(__doc__, version="0.0.1").iteritems()}
        if kwargs["verbose"]:
            pprint(kwargs)

        # Initialize and process.
        codepoint = Codepoint(**kwargs)

        # Display internal data as flagged on the command-line.
        codepoint.shows()

        # Generate an ANTLR4 grammar
        codepoint.g4()

        if codepoint.unittest:
            # Run unit tests.
            TheTest.codepoint = codepoint

            # internal test
            codepoint.test()

            # using unittest
            if kwargs["verbose"]:
                unittest.main()
Beispiel #8
0
    def run(self):
        os.setpgrp()

        unittest_args = [sys.argv[0]]
        if ARGS.verbose:
            unittest_args += ["-v"]
        unittest.main(argv=unittest_args)
Beispiel #9
0
def main():
    URL = "http://mangal.io:8080"
    if len(sys.argv) > 1:
        for i in range(len(sys.argv) - 1):
            if sys.argv[i] in ["-h", "--host"]:
                if sys.argv[i + 1] == "local":
                    URL = "http://127.0.0.1:8000"
                else:
                    URL = sys.argv[i + 1]
                del (sys.argv[i + 1])
                del (sys.argv[i])
    print "Testing on host " + URL + "\n"
    USER = "test"
    KEY = "9d00823baa5be60d788d079143d9785a4ffd3eec"
    ## Cleaning DB
    mg = api.mangal(URL, usr=USER, key=KEY)
    re.delete(mg.root + "/api/v1/taxa/")
    ##
    os.environ["mg_test_url"] = URL
    os.environ["mg_test_usr"] = USER
    os.environ["mg_test_key"] = KEY
    if sys.version_info[1] < 7:
        unittest.main()
    else:
        unittest.main(verbosity=1)
Beispiel #10
0
def runConsole(single_test, avoid_integration, argv):
    if single_test is None:
        if os.name == "posix":
            os.system("clear")
        module = None
    else:
        module_name = single_test[:-3].replace(os.sep, ".")
        module = __import__(module_name, globals(), locals(), [str(module_name)])

    old_sys_exit = sys.exit

    def _exit(status=0):
        global EXIT_VALUE
        EXIT_VALUE = status

    sys.exit = _exit
    global AVOID_INTEGRATION
    AVOID_INTEGRATION = avoid_integration
    sys.argv = argv
    if module is None:
        unittest.main(defaultTest="suite")
    else:
        unittest.main(module=module, defaultTest="suite")
    debugThreads()
    old_sys_exit(EXIT_VALUE)
Beispiel #11
0
def iMain(lCmdLine):

    if "--test" in lCmdLine:
        # legacy - unused
        sys.argv = [sys.argv[0]]  # the --test argument upsets unittest.main()
        unittest.main()
        return 0

    oApp = None
    try:
        oApp = oMain(lCmdLine)
        if oApp.oOptions.lArgs:
            oApp.onecmd_plus_hooks(" ".join(oApp.oOptions.lArgs) + "\n")
        else:
            oApp._cmdloop()
    except KeyboardInterrupt:
        pass
    except Exception as e:
        print (traceback.format_exc(10))
    # always reached
    if oApp:
        oApp.vAtexit()

        l = threading.enumerate()
        if len(l) > 1:
            print "WARN: Threads still running: %r" % (l,)
Beispiel #12
0
def main():
    """
    This runs the our tests, suitable for a command-line application
    """
    unittest.main(defaultTest="suite", exit=False)
    print("Number of assertions: {0}".format(BaseTestCase.number_of_assertions))
    print("")
Beispiel #13
0
    def run_tests(self):
        import sys, os

        if sys.version_info[0] == 3:
            rootdir = os.path.dirname(os.path.abspath(__file__))
            if rootdir in sys.path:
                sys.path.remove(rootdir)

        ei_cmd = self.get_finalized_command("egg_info")
        egg_name = ei_cmd.egg_name.replace("-", "_")

        to_remove = []
        for dirname in sys.path:
            bn = os.path.basename(dirname)
            if bn.startswith(egg_name + "-"):
                to_remove.append(dirname)

        for dirname in to_remove:
            log.info("removing installed %r from sys.path before testing" % (dirname,))
            sys.path.remove(dirname)

        from PyObjCTest.loader import makeTestSuite
        import unittest

        # import pprint; pprint.pprint(sys.path)

        unittest.main(None, None, [unittest.__file__] + self.test_args)
Beispiel #14
0
def main():
    import sys, logging

    if "-d" in sys.argv:
        logging.getLogger().setLevel(logging.DEBUG)
        sys.argv.remove("-d")
    unittest.main()
def test_main():
    try:
        from test import test_support

        test_support.run_unittest(test_ClusterNodeNic)
    except ImportError:
        unittest.main()
Beispiel #16
0
def main():
    # grind to look for errors
    GRINDS = 10000
    MAX_POWER = 20
    for i in xrange(GRINDS):
        power_d = random.randint(0, MAX_POWER - 2)
        belt_a = [random.randint(1, 1000) for j in xrange(power_d)]
        belt_b = [random.randint(1, 1000) for j in xrange(MAX_POWER - 2 - power_d)]
        h = Handle(belt_a[:], belt_b[:], MAX_POWER)
        max_sum = sum(sorted(belt_a + belt_b, reverse=True)[:2])
        poor_sum_msgs = []
        poor_sum_r = []
        try:
            h.run()
            if h.sum() < max_sum:
                poor_sum_msgs.append("%d < %d: %s, %s" % (h.sum(), max_sum, belt_a, belt_b))
                poor_sum_r.append("Report %d" % len(poor_sum_msgs))
                poor_sum_r.append("=====")
                poor_sum_r.extend(h.msgs)
        except:
            print "\n".join(h.report())
            raise

    print "POOR SUMS @MAX_POWER: (%d of %d)" % (len(poor_sum_msgs), GRINDS)
    for line in poor_sum_msgs[:100]:
        print line

    #  for line in poor_sum_r[:200]:
    #    print line

    unittest.main()
Beispiel #17
0
def main():
    try:
        unittest.main()
        # suite = unittest.TestLoader().loadTestsFromTestCase(JsonTest)
        # unittest.TextTestRunner(verbosity=2).run(suite)
    finally:
        measureThroughput()
Beispiel #18
0
def main(args):
    """
  main entry point for the GenomicIntJaccard script.

  :param args: the arguments for this script, as a list of string. Should
               already have had things like the script name stripped. That
               is, if there are no args provided, this should be an empty
               list.
  """
    # get options and arguments
    ui = getUI(args)

    if ui.optionIsSet("test"):
        # just run unit tests
        unittest.main(argv=[sys.argv[0]])
    elif ui.optionIsSet("help"):
        # just show help
        ui.usage()
    else:
        verbose = ui.optionIsSet("verbose")
        stranded = ui.optionIsSet("stranded")

        if stranded:
            sys.stderr.write("Sorry, stranded mode hasn't been implemented yet.")
            sys.exit()

        # we required two input files, so we know these will be present...
        regions_1 = [e for e in BEDIterator(ui.getArgument(0), verbose=verbose)]
        regions_2 = [e for e in BEDIterator(ui.getArgument(1), verbose=verbose)]

        print jaccardIndex(regions_1, regions_2)
Beispiel #19
0
    def run(self):
        # Change to project root to run tests
        project_root = os.path.dirname(__file__)
        if project_root:
            os.chdir(project_root)

        # Set up environment to point to mockup files.
        test_path = os.path.join(os.getcwd(), "tests", "data")
        os.environ["TRIGGER_SETTINGS"] = os.path.join(test_path, "settings.py")
        os.environ["NETDEVICES_SOURCE"] = os.path.join(test_path, "netdevices.xml")
        os.environ["AUTOACL_FILE"] = os.path.join(test_path, "autoacl.py")
        os.environ["BOUNCE_FILE"] = os.path.join(test_path, "bounce.py")
        os.environ["TACACSRC"] = os.path.join(test_path, "tacacsrc")
        os.environ["TACACSRC_KEYFILE"] = os.path.join(test_path, "tackf")

        # Run each .py file found under tests.
        args = [unittest.__file__]
        for root, dirs, files in os.walk("tests"):
            for fn in files:
                if fn.startswith("test") and fn.endswith(".py"):
                    args.append(fn[:-3])

        # Inject tests dir into beginning of sys.path before we run the tests
        sys.path.insert(0, os.path.join(os.getcwd(), "tests"))
        unittest.main(None, None, args)