Skip to content

Commit

Permalink
test: add tests for managing selenium webdriver
Browse files Browse the repository at this point in the history
  • Loading branch information
sqr00t committed Jan 5, 2024
1 parent becb0a6 commit 745f6d2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/viz/altair/test_saving.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import shutil
from pathlib import Path
from nesta_ds_utils.viz.altair import saving
from selenium.webdriver.chromium.webdriver import ChromiumDriver
import pandas as pd
import altair as alt
import pytest
Expand Down Expand Up @@ -41,3 +42,18 @@ def test_save_altair_exception():
saving.save(
fig, "test_fig", path, save_png=False, save_html=False, save_svg=False
)


def test_webdriver():
"""Test that Chrome WebDriver is created by default is a ChromiumDriver, and context manager stops the webdriver."""
driver = saving._google_chrome_driver_setup()
assert isinstance(driver, ChromiumDriver)

with saving.webdriver_context(driver) as some_driver:
# No actions needed here,
# just testing that the context manager calls .quit() on driver to terminate.
pass

# If subprocess not terminated, .poll() returns None
# https://docs.python.org/3/library/subprocess.html#subprocess.Popen.returncode
assert driver.service.process.poll() is not None

0 comments on commit 745f6d2

Please sign in to comment.