Skip to content

Commit 7d44687

Browse files
committed
fix phantomjs
1 parent 53ac881 commit 7d44687

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ jobs:
1717
python-version: "3.x"
1818
- run: pip install .
1919
- run: pip install pytest
20-
- run: pytest
20+
- run: pytest -vs

src/htmlcmp/html_render_diff.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4+
import shutil
45
import sys
56
import argparse
67
import io
@@ -70,6 +71,8 @@ def get_browser(
7071
)
7172

7273
if driver == "phantomjs":
74+
if shutil.which("phantomjs") is None:
75+
raise EnvironmentError("PhantomJS is not installed or not found in PATH")
7376
browser = webdriver.PhantomJS()
7477
elif driver == "firefox":
7578
options = webdriver.FirefoxOptions()

tests/test_html_render_diff.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22
from pathlib import Path
3+
import shutil
34

45
from htmlcmp.html_render_diff import to_url, get_browser, html_render_diff
56

@@ -31,9 +32,10 @@ def test_get_browser():
3132
browser.quit()
3233

3334
# Test with PhantomJS
34-
browser = get_browser("phantomjs")
35-
assert browser.name == "phantomjs"
36-
browser.quit()
35+
if shutil.which("phantomjs") is not None:
36+
browser = get_browser("phantomjs")
37+
assert browser.name == "phantomjs"
38+
browser.quit()
3739

3840

3941
def test_html_render_diff():

0 commit comments

Comments
 (0)