Esempio n. 1
0
  def run_from_argv(self, argv):
    """
    Runs the tests.

    This management command is unusual in that it doesn't
    use Django's normal argument handling.  (If it did, this
    method would be callled handle().)  We do so to more
    easily pass arbitrary arguments to nose.
    """
    args = argv[2:] # First two are "desktop" and "test"

    # Patch South things in
    south.management.commands.patch_for_test_db_setup()
    south_logger = logging.getLogger('south')
    south_logger.setLevel(logging.INFO)

    if len(args) == 0:
      print self.help
      sys.exit(1)

    nose_args = None
    all_apps = [ app.module.__name__ for app in appmanager.DESKTOP_MODULES ]

    if args[0] == "all":
      nose_args = args + all_apps
    elif args[0] == "impala":
      if len(args) > 1:
        from impala.conf import SERVER_HOST
        SERVER_HOST.set_for_testing(args[1])
      nose_args = ["specific", "impala"]
      args = ["specific"]
    elif args[0] == "fast":
      nose_args = args + all_apps + ["-a", "!requires_hadoop"]
    elif args[0] == "windmill":
      args = args[1:]
      ret = test_windmill.Command().handle(*args)
    elif args[0] in ("specific", "nose"):
      nose_args = args
    else:
      print self.help
      sys.exit(1)

    if nose_args:
      TestRunner = get_runner(settings)
      test_runner = TestRunner(verbosity=1, interactive=False)
      nose_args.remove(args[0])
      ret = test_runner.run_tests(nose_args)

    logging.info("Tests (%s) returned %s" % (' '.join(nose_args), ret))

    if ret != 0:
      sys.exit(1)
Esempio n. 2
0
  def run_from_argv(self, argv):
    """
    Runs the tests.

    This management command is unusual in that it doesn't
    use Django's normal argument handling.  (If it did, this
    method would be callled handle().)  We do so to more
    easily pass arbitrary arguments to nose.
    """
    args = argv[2:] # First two are "desktop" and "test"

    # Patch South things in
    south.management.commands.syncdb.patch_for_test_db_setup()

    if len(args) == 0:
      print self.help
      sys.exit(1)

    nose_args = None
    all_apps = [ app.module.__name__ for app in appmanager.DESKTOP_MODULES ]

    if args[0] == "all":
      nose_args = args + all_apps + ["-v"]
    elif args[0] == "fast":
      test_apps = [ app.module.__name__ for app in appmanager.DESKTOP_MODULES ]
      nose_args = args + all_apps + ["-v", "-a", "!requires_hadoop"]
    elif args[0] in ("specific", "nose"):
      nose_args = args + ['-v']
    elif args[0] == "windmill":
      args = args[1:]
      ret = test_windmill.Command().handle(*args)
    else:
      print self.help
      sys.exit(1)

    if nose_args:
      ret = nose_runner.run_tests_explicit(nose_args, interactive=True, verbosity=1)

    logging.info("Tests (%s) returned %s" % (' '.join(nose_args), ret))

    if not ret:
      sys.exit(1)