Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions mypy/test/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ def check_test_output_files(
if testcase.suite.native_sep and os.path.sep == "\\":
normalized_output = [fix_cobertura_filename(line) for line in normalized_output]
normalized_output = normalize_error_messages(normalized_output)
if os.path.basename(testcase.file) == "reports.test":
normalized_output = normalize_report_meta(normalized_output)
assert_string_arrays_equal(
expected_content.splitlines(),
normalized_output,
Expand All @@ -467,6 +469,13 @@ def normalize_file_output(content: list[str], current_abs_path: str) -> list[str
return result


def normalize_report_meta(content: list[str]) -> list[str]:
# libxml 2.15 and newer emits the "modern" version of this <meta> element.
# Normalize the old style to look the same.
html_meta = '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'
return ['<meta charset="UTF-8">' if x == html_meta else x for x in content]


def find_test_files(pattern: str, exclude: list[str] | None = None) -> list[str]:
return [
path.name
Expand Down
12 changes: 6 additions & 6 deletions test-data/unit/reports.test
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class A(object):
[outfile report/html/n.py.html]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="../mypy-html.css">
</head>
<body>
Expand Down Expand Up @@ -172,7 +172,7 @@ T = TypeVar('T')
[outfile report/html/n.py.html]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="../mypy-html.css">
</head>
<body>
Expand Down Expand Up @@ -214,7 +214,7 @@ def bar(x):
[outfile report/html/n.py.html]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="../mypy-html.css">
</head>
<body>
Expand Down Expand Up @@ -255,7 +255,7 @@ old_stdout = sys.stdout
[outfile report/html/n.py.html]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="../mypy-html.css">
</head>
<body>
Expand Down Expand Up @@ -487,7 +487,7 @@ DisplayToSource = Callable[[int], int]
[outfile report/html/n.py.html]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="../mypy-html.css">
</head>
<body>
Expand Down Expand Up @@ -529,7 +529,7 @@ namespace_packages = True
[outfile report/html/folder/subfolder/something.py.html]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="../../../mypy-html.css">
</head>
<body>
Expand Down