Skip to content

Commit 85f9adb

Browse files
committed
Permit another doctype opener that is output on earlier versions of Python.
1 parent 8b11cf2 commit 85f9adb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tests/support/htmlsupp.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727

2828
"""Test support library for HTML."""
2929

30+
_POSSIBLE_DOCTYPE_OPENERS =[
31+
"<!DOCTYPE HTML",
32+
"<!DOCTYPE html",
33+
"<!doctype html",
34+
]
35+
3036

3137
class HtmlAssertMixin:
3238
"""Custom assertions for HTML containing strings."""
@@ -58,7 +64,10 @@ def assertIsValidHtmlDocument(self, value, permit_no_close=False):
5864

5965
error = None
6066
try:
61-
has_doctype = value.startswith("<!DOCTYPE html") or value.startswith("<!doctype html")
67+
for opener in _POSSIBLE_DOCTYPE_OPENERS:
68+
has_doctype = value.startswith(opener)
69+
if has_doctype:
70+
break
6271
assert has_doctype, "no valid document opener"
6372
end_html_tag_idx = value.rfind('</html>')
6473
if end_html_tag_idx == -1 and permit_no_close:

0 commit comments

Comments
 (0)