File: normalize-html-content-type-meta.patch

package info (click to toggle)
mypy 1.18.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 21,656 kB
  • sloc: python: 112,065; cpp: 11,380; ansic: 8,045; makefile: 247; sh: 27
file content (98 lines) | stat: -rw-r--r-- 3,529 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
From: STerliakov <terlya.stas@gmail.com>
Date: Fri, 7 Nov 2025 05:02:02 +0100
Subject: Normalize HTML content-type meta

Origin: upstream, https://github.com/python/mypy/pull/20199
Bug: https://github.com/python/mypy/issues/20070
Bug-Debian: https://bugs.debian.org/1120242
Last-Update: 2025-11-09
---
 mypy/test/helpers.py        |  9 +++++++++
 test-data/unit/reports.test | 12 ++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/mypy/test/helpers.py b/mypy/test/helpers.py
index ae432ff..97f40c2 100644
--- a/mypy/test/helpers.py
+++ b/mypy/test/helpers.py
@@ -441,6 +441,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,
@@ -464,6 +466,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
diff --git a/test-data/unit/reports.test b/test-data/unit/reports.test
index 82c3869..e9ee76f 100644
--- a/test-data/unit/reports.test
+++ b/test-data/unit/reports.test
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>