()
locusts entrance
locusts entrance
locusts entrance
def main_locusts():
    """ locusts entrance
    """
    from httprunner.utils import init_sentry_sdk
    from sentry_sdk import capture_message

    init_sentry_sdk()
    capture_message("start to run locusts")

    # avoid print too much log details in console
    logger.remove()
    logger.add(sys.stderr, level="WARNING")

    sys.argv[0] = "locust"
    if len(sys.argv) == 1:
        sys.argv.extend(["-h"])

    if sys.argv[1] in ["-h", "--help", "-V", "--version"]:
        locust_main.main()

    def get_arg_index(*target_args):
        for arg in target_args:
            if arg not in sys.argv:
                continue

            return sys.argv.index(arg) + 1

        return None

    # get testcase file path
    testcase_index = get_arg_index("-f", "--locustfile")
    if not testcase_index:
        print("Testcase file is not specified, exit 1.")
        sys.exit(1)

    from httprunner.make import main_make

    global pytest_files
    testcase_file_path = sys.argv[testcase_index]
    pytest_files = main_make([testcase_file_path])
    if not pytest_files:
        print("No valid testcases found, exit 1.")
        sys.exit(1)

    sys.argv[testcase_index] = os.path.join(os.path.dirname(__file__), "locustfile.py")

    locust_main.main()
def main_locusts ( ) : from httprunner . utils import init_sentry_sdk from sentry_sdk import capture_message init_sentry_sdk ( ) capture_message ( "start to run locusts" ) # avoid print too much log details in console logger . remove ( ) logger . add ( sys . stderr , level = "WARNING" ) sys . argv [ 0 ] = "locust" if len ( sys . argv ) == 1 : sys . argv . extend ( [ "-h" ] ) if sys . argv [ 1 ] in [ "-h" , "--help" , "-V" , "--version" ] : locust_main . main ( ) def get_arg_index ( * target_args ) : for arg in target_args : if arg not in sys . argv : continue return sys . argv . index ( arg ) + 1 return None # get testcase file path testcase_index = get_arg_index ( "-f" , "--locustfile" ) if not testcase_index : print ( "Testcase file is not specified, exit 1." ) sys . exit ( 1 ) from httprunner . make import main_make global pytest_files testcase_file_path = sys . argv [ testcase_index ] pytest_files = main_make ( [ testcase_file_path ] ) if not pytest_files : print ( "No valid testcases found, exit 1." ) sys . exit ( 1 ) sys . argv [ testcase_index ] = os . path . join ( os . path . dirname ( __file__ ) , "locustfile.py" ) locust_main . main ( )