Repository: servo/servo
File: etc/ci/scenario/update_mitmproxy_dump.py (Python)

Code before:


class colors:
    GREEN = "\033[92m"
    ENDC = "\033[0m"


def google_test():
    IMPLICIT_WAIT_TIME = 6
    PAGE_URL = "https://www.google.com"
    driver = common_function_for_servo_test.create_driver()
    driver.get(PAGE_URL)
    print("Page loaded.")
    driver.implicitly_wait(IMPLICIT_WAIT_TIME)


def run_test(name: str, f):
    print(colors.GREEN + name + colors.ENDC)
    try:
        common_function_for_servo_test.run_test(f, "servo", common_function_for_servo_test.MitmProxyRunType.RECORD)
    except Exception:
        print(f"Test {name} failed")


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Create a mitmdump file from google, servo and scenariotest")
    parser.add_argument("dump_file", type=str, help="the file we write the dump to")
    args = parser.parse_args()

    mitmproxy = subprocess.Popen(
        [
            "mitmdump",
            "-w",
            args.dump_file,
            "-p",
            common_function_for_servo_test.MITMPROXY_PORT,
            # "--mode", "upstream:<YOUR_PROXY_ADDRESS>",
            "--set",
            "ssl_insecure=true",
        ]
    )
    print(f"Writing to {args.dump_file}")

    time.sleep(5)
    run_test("Running servo_test_open_page_servo", servo_test_open_page_servo.operator)
    run_test("Running servo_test_open_page_base", servo_test_open_page_base.operator)
    run_test("Running servo_test_redirection", servo_test_redirection.operator)
    run_test("Running servo_test_slide", servo_test_slide.operator)
    run_test("Running Servo Speedometer", servo_speedometer.run_speedometer)
    run_test("Google", google_test)


Review comment (suggestion):
```suggestion
    parser = argparse.ArgumentParser(description="Create a mitmdump file from google, servo, speedometer and scenario tests")
```

Code after:


class colors:
    GREEN = "\033[92m"
    ENDC = "\033[0m"


def google_test():
    IMPLICIT_WAIT_TIME = 6
    PAGE_URL = "https://www.google.com"
    driver = common_function_for_servo_test.create_driver()
    driver.get(PAGE_URL)
    print("Page loaded.")
    driver.implicitly_wait(IMPLICIT_WAIT_TIME)


def run_test(name: str, f):
    print(colors.GREEN + name + colors.ENDC)
    try:
        common_function_for_servo_test.run_test(f, "servo", common_function_for_servo_test.MitmProxyRunType.RECORD)
    except Exception:
        print(f"Test {name} failed")


if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description="Create a mitmdump file from google, servo, speedometer and scenario tests"
    )
    parser.add_argument("dump_file", type=str, help="the file we write the dump to")
    args = parser.parse_args()

    mitmproxy = subprocess.Popen(
        [
            "mitmdump",
            "-w",
            args.dump_file,
            "-p",
            common_function_for_servo_test.MITMPROXY_PORT,
            # "--mode", "upstream:<YOUR_PROXY_ADDRESS>",
            "--set",
            "ssl_insecure=true",
        ]
    )
    print(f"Writing to {args.dump_file}")

    time.sleep(5)
    run_test("Running servo_test_open_page_servo", servo_test_open_page_servo.operator)
    run_test("Running servo_test_open_page_base", servo_test_open_page_base.operator)
    run_test("Running servo_test_redirection", servo_test_redirection.operator)
    run_test("Running servo_test_slide", servo_test_slide.operator)
    run_test("Running Servo Speedometer", servo_speedometer.run_speedometer)