'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.'

def run_from_argv(self, argv):

    args = argv[2:]
    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] == '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
    elif (args[0] == 'list_modules'):
        print '\n'.join(all_apps)
        sys.exit(0)
    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)
