Skip to content

Commit b31698f

Browse files
srittauJelleZijlstra
authored andcommitted
Use custom function instead of print() in tests (#6534)
This removes coupling to the exact type annotation of print() in typeshed. Cf. python/typeshed#2848
1 parent 892b8d8 commit b31698f

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

test-data/unit/reports.test

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,18 @@ T = TypeVar('T')
140140
[case testUnreachableCodeMarkedAsAny]
141141
# cmd: mypy --html-report report n.py
142142

143+
[file any.py]
144+
from typing import Any
145+
def any_f(x: Any) -> None:
146+
pass
147+
143148
[file n.py]
149+
from any import any_f
144150
def bar(x):
145151
# type: (str) -> None
146-
print(x)
152+
any_f(x)
147153
assert False
148-
print(x)
154+
any_f(x)
149155

150156
[file report/mypy-html.css]
151157
[file report/index.html]
@@ -165,13 +171,15 @@ def bar(x):
165171
<span id="L3" class="lineno"><a class="lineno" href="#L3">3</a></span>
166172
<span id="L4" class="lineno"><a class="lineno" href="#L4">4</a></span>
167173
<span id="L5" class="lineno"><a class="lineno" href="#L5">5</a></span>
174+
<span id="L6" class="lineno"><a class="lineno" href="#L6">6</a></span>
168175
</pre></td>
169-
<td class="table-code"><pre><span class="line-precise" title="No Anys on this line!">def bar(x):</span>
176+
<td class="table-code"><pre><span class="line-empty" title="No Anys on this line!">from any import any_f</span>
177+
<span class="line-precise" title="No Anys on this line!">def bar(x):</span>
170178
<span class="line-empty" title="No Anys on this line!"> # type: (str) -&gt; None</span>
171179
<span class="line-precise" title="Any Types on this line:
172-
Explicit (x1)"> print(x)</span>
180+
Explicit (x1)"> any_f(x)</span>
173181
<span class="line-empty" title="No Anys on this line!"> assert False</span>
174-
<span class="line-unanalyzed" title="No Anys on this line!"> print(x)</span>
182+
<span class="line-unanalyzed" title="No Anys on this line!"> any_f(x)</span>
175183
</pre></td>
176184
</tr></tbody>
177185
</table>
@@ -287,8 +295,11 @@ Total 0 16 100.00%
287295
from typing import Any, List
288296
from nonexistent import C # type: ignore
289297

298+
def any_f(x: Any) -> None: # Explicit
299+
pass
300+
290301
def a(x) -> None: # Unannotated
291-
print(x)
302+
any_f(x)
292303

293304
x: Any = 2 # Explicit
294305
y: C = None # Unimported
@@ -304,9 +315,9 @@ z = g.does_not_exist() # type: ignore # Error
304315
[outfile report/types-of-anys.txt]
305316
Name Unannotated Explicit Unimported Omitted Generics Error Special Form Implementation Artifact
306317
-----------------------------------------------------------------------------------------------------------------
307-
n 2 3 2 1 3 0 0
318+
n 2 4 2 1 3 0 0
308319
-----------------------------------------------------------------------------------------------------------------
309-
Total 2 3 2 1 3 0 0
320+
Total 2 4 2 1 3 0 0
310321

311322
[case testAnyExpressionsReportUnqualifiedError]
312323
# cmd: mypy --any-exprs-report report n.py

0 commit comments

Comments
 (0)