Skip to content

Commit 9e4ef72

Browse files
PhilippSeleniumPhilippSelenium
andauthored
Fix report tests for pytest-html >= 2.0.0 (#240)
Co-authored-by: PhilippSelenium <[email protected]>
1 parent d1d4ff6 commit 9e4ef72

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

testing/test_report.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,24 @@
55
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
66

77
import re
8+
from distutils.version import LooseVersion
89

910
import pytest
11+
from pytest_html import __version__ as PYTEST_HTML_VERSION
1012

1113
pytestmark = pytest.mark.nondestructive
1214

1315
URL_LINK = '<a class="url" href="{0}/" target="_blank">URL</a>'
14-
SCREENSHOT_LINK_REGEX = (
15-
'<a class="image" href=".*" target="_blank">Screenshot</a>'
16-
) # noqa
17-
SCREENSHOT_REGEX = '<div class="image"><a href=".*"><img src=".*"/></a></div>'
16+
17+
if LooseVersion(PYTEST_HTML_VERSION) < LooseVersion("2.0.0"):
18+
SCREENSHOT_LINK_REGEX = '<a class="image" href=".*" target="_blank">Screenshot</a>'
19+
SCREENSHOT_REGEX = '<div class="image"><a href=".*"><img src=".*"/></a></div>'
20+
else:
21+
SCREENSHOT_LINK_REGEX = '<a class="image" href=".*" target="_blank"></a>'
22+
SCREENSHOT_REGEX = (
23+
'<div class="image"><a class="image" href=".*" target="_blank"></a></div>'
24+
)
25+
1826
LOGS_REGEX = '<a class="text" href=".*" target="_blank">.* Log</a>'
1927
HTML_REGEX = '<a class="text" href=".*" target="_blank">HTML</a>'
2028

0 commit comments

Comments
 (0)