From e6957ec2524b833426e8936e552563e838346e74 Mon Sep 17 00:00:00 2001 From: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com> Date: Sat, 5 Apr 2025 12:30:39 -0400 Subject: [PATCH 1/2] [py] Fix broken test for chromedriver logging --- .../webdriver/chrome/chrome_service_tests.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/py/test/selenium/webdriver/chrome/chrome_service_tests.py b/py/test/selenium/webdriver/chrome/chrome_service_tests.py index c3b3360c939c4..4ca3e793e797b 100644 --- a/py/test/selenium/webdriver/chrome/chrome_service_tests.py +++ b/py/test/selenium/webdriver/chrome/chrome_service_tests.py @@ -30,17 +30,24 @@ def test_uses_chromedriver_logging(clean_driver, driver_executable) -> None: log_file = "chromedriver.log" service_args = ["--append-log"] - service = Service( + service1 = Service( log_output=log_file, service_args=service_args, executable_path=driver_executable, ) + + service2 = Service( + log_output=log_file, + service_args=service_args, + executable_path=driver_executable, + ) + driver2 = None try: - driver1 = clean_driver(service=service) + driver1 = clean_driver(service=service1) with open(log_file) as fp: lines = len(fp.readlines()) - driver2 = clean_driver(service=service) + driver2 = clean_driver(service=service2) with open(log_file) as fp: assert len(fp.readlines()) >= 2 * lines finally: From c53d0cf13971bf60c9bc34a8870a9a82061e1924 Mon Sep 17 00:00:00 2001 From: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com> Date: Sat, 5 Apr 2025 20:48:52 -0400 Subject: [PATCH 2/2] [py] Fix problem with driver cleanup in test --- py/test/selenium/webdriver/chrome/chrome_service_tests.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/py/test/selenium/webdriver/chrome/chrome_service_tests.py b/py/test/selenium/webdriver/chrome/chrome_service_tests.py index 4ca3e793e797b..ce0a6fcc25237 100644 --- a/py/test/selenium/webdriver/chrome/chrome_service_tests.py +++ b/py/test/selenium/webdriver/chrome/chrome_service_tests.py @@ -42,6 +42,7 @@ def test_uses_chromedriver_logging(clean_driver, driver_executable) -> None: executable_path=driver_executable, ) + driver1 = None driver2 = None try: driver1 = clean_driver(service=service1) @@ -51,7 +52,8 @@ def test_uses_chromedriver_logging(clean_driver, driver_executable) -> None: with open(log_file) as fp: assert len(fp.readlines()) >= 2 * lines finally: - driver1.quit() + if driver1: + driver1.quit() if driver2: driver2.quit() os.remove(log_file)