|
6 | 6 | from unittest.mock import AsyncMock, patch |
7 | 7 |
|
8 | 8 | import pytest |
| 9 | +from choreographer.browsers import chromium |
9 | 10 | from hypothesis import HealthCheck, given, settings |
10 | 11 | from hypothesis import strategies as st |
11 | 12 |
|
12 | 13 | from kaleido import Kaleido |
| 14 | +from kaleido.errors import ChromeNotFoundError |
13 | 15 |
|
14 | 16 | if TYPE_CHECKING: |
15 | 17 | from collections.abc import AsyncGenerator, Generator |
@@ -338,6 +340,22 @@ async def test_kaleido_instantiate_and_close(): |
338 | 340 | await k.close() |
339 | 341 |
|
340 | 342 |
|
| 343 | +async def test_kaleido_reports_bad_path(): |
| 344 | + """Test that a browser path passed by the user is named in the error.""" |
| 345 | + with pytest.raises(ChromeNotFoundError, match="path='/nonexistent/chrome'"): |
| 346 | + Kaleido(path="/nonexistent/chrome") |
| 347 | + |
| 348 | + |
| 349 | +async def test_kaleido_reports_bad_browser_path_env(monkeypatch): |
| 350 | + """Test that a BROWSER_PATH set by the user is named in the error.""" |
| 351 | + monkeypatch.setenv("BROWSER_PATH", "/nonexistent/chrome") |
| 352 | + # a downloaded chrome takes precedence over BROWSER_PATH, so hide it |
| 353 | + monkeypatch.setattr(chromium, "get_chrome_download_path", lambda **_: None) |
| 354 | + monkeypatch.setattr(chromium, "get_old_chrome_download_path", lambda: None) |
| 355 | + with pytest.raises(ChromeNotFoundError, match="BROWSER_PATH='/nonexistent/chrome'"): |
| 356 | + Kaleido() |
| 357 | + |
| 358 | + |
341 | 359 | async def test_all_methods_context(simple_figure_with_bytes, tmp_path): |
342 | 360 | """Test write, write_from_object, and calc with context.""" |
343 | 361 | fig = simple_figure_with_bytes["fig"] |
|
0 commit comments