Skip to content

Commit 1013b63

Browse files
authored
Enable a bunch of skipped tests (python#8024)
This PR enables all skipped tests that can be enabled. There are still 24 skipped tests left that still fail.
1 parent 771cf2b commit 1013b63

12 files changed

+53
-48
lines changed

mypy/test/testparse.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
"""Tests for the mypy parser."""
22

3+
import sys
4+
5+
from pytest import skip # type: ignore[import]
6+
37
from mypy import defaults
4-
from mypy.test.helpers import assert_string_arrays_equal
8+
from mypy.test.helpers import assert_string_arrays_equal, parse_options
59
from mypy.test.data import DataDrivenTestCase, DataSuite
610
from mypy.parse import parse
711
from mypy.errors import CompileError
@@ -60,9 +64,12 @@ def run_case(self, testcase: DataDrivenTestCase) -> None:
6064

6165
def test_parse_error(testcase: DataDrivenTestCase) -> None:
6266
try:
67+
options = parse_options('\n'.join(testcase.input), testcase, 0)
68+
if options.python_version != sys.version_info[:2]:
69+
skip()
6370
# Compile temporary file. The test file contains non-ASCII characters.
6471
parse(bytes('\n'.join(testcase.input), 'utf-8'), INPUT_FILE_NAME, '__main__', None,
65-
Options())
72+
options)
6673
raise AssertionError('No errors reported')
6774
except CompileError as e:
6875
if e.module_with_blocker is not None:

test-data/unit/check-generics.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ def g3(f: Callable[[object], object]) -> None: pass
16081608
g3(f) # E: Argument 1 to "g3" has incompatible type "Callable[[T], T]"; \
16091609
expected "Callable[[object], object]"
16101610

1611-
[case testSubtypingWithGenericFunctionUsingTypevarWithValues2-skip]
1611+
[case testSubtypingWithGenericFunctionUsingTypevarWithValues2]
16121612
from typing import TypeVar, Callable
16131613
T = TypeVar('T', int, str)
16141614
def f(x: T) -> T: pass

test-data/unit/check-incremental.test

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3600,8 +3600,7 @@ x = 1
36003600
[file b.py.2]
36013601
x = '2'
36023602

3603-
-- TODO: Fails due to #4856
3604-
[case testImportUnusedIgnore2-skip]
3603+
[case testImportUnusedIgnore2]
36053604
# flags: --warn-unused-ignores
36063605
import a
36073606
[file a.py]
@@ -3616,7 +3615,7 @@ pass
36163615
[out]
36173616
[out2]
36183617
[out3]
3619-
tmp/a.py:1: note: unused 'type: ignore' comment
3618+
tmp/a.py:2: error: unused 'type: ignore' comment
36203619

36213620
-- Test that a non cache_fine_grained run can use a fine-grained cache
36223621
[case testRegularUsesFgCache]

test-data/unit/check-inference.test

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,9 +2400,8 @@ class C(B):
24002400
reveal_type(B.x) # N: Revealed type is 'None'
24012401
reveal_type(C.x) # N: Revealed type is 'None'
24022402

2403-
[case testLocalPartialTypesWithInheritance2-skip]
2403+
[case testLocalPartialTypesWithInheritance2]
24042404
# flags: --local-partial-types
2405-
# This is failing because of https://github.com/python/mypy/issues/4552
24062405
from typing import Optional
24072406

24082407
class X: pass
@@ -2415,7 +2414,7 @@ class B(A):
24152414
x = None
24162415
x = Y()
24172416

2418-
reveal_type(B.x) # E: revealed type is 'Union[__main__.Y, None]'
2417+
reveal_type(B.x) # N: Revealed type is 'Union[__main__.Y, None]'
24192418

24202419
[case testLocalPartialTypesBinderSpecialCase]
24212420
# flags: --local-partial-types

test-data/unit/check-isinstance.test

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,27 @@ def f(x: Union[int, str, List]) -> None:
4848
reveal_type(x) # N: Revealed type is 'Union[builtins.int, builtins.str, builtins.list[Any]]'
4949
[builtins fixtures/isinstancelist.pyi]
5050

51-
[case testClassAttributeInitialization-skip]
51+
[case testClassAttributeInitialization]
5252
class A:
5353
x = None # type: int
5454
def __init__(self) -> None:
5555
self.y = None # type: int
5656
z = self.x
5757
w = self.y
5858

59-
[case testAssignmentSubtypes-skip]
59+
[case testAssignmentSubtypes]
6060
from typing import Union
6161

6262
def foo(x: Union[str, int]):
6363
if isinstance(x, int):
6464
x = 'a'
65-
x + 'a' # Works in the current code
66-
z = x # We probably want this to be of type str.
67-
y = [x] # But what type should this be?
68-
y[0] + 'a' # (1) Should this work?
69-
y + [1] # (2) Or this?
70-
z = 1 # Also, is this valid?
65+
x + 'a'
66+
z = x
67+
y = [x]
68+
y[0] + 'a'
69+
# TODO: should we allow these two lines?
70+
y + [1] # E: List item 0 has incompatible type "int"; expected "str"
71+
z = 1 # E: Incompatible types in assignment (expression has type "int", variable has type "str")
7172

7273
x = None # type: int
7374
y = [x]
@@ -116,9 +117,9 @@ if int():
116117
x.z # E: "A" has no attribute "z"
117118
x.y
118119

119-
[case testSingleMultiAssignment-skip]
120+
[case testSingleMultiAssignment]
120121
x = 'a'
121-
(x, ) = ('a',)
122+
(x,) = ('a',)
122123

123124
[case testUnionMultiAssignment]
124125
from typing import Union
@@ -595,22 +596,23 @@ assert isinstance(b, (A, B, C))
595596
reveal_type(b) # N: Revealed type is 'Union[__main__.A, __main__.B]'
596597
[builtins fixtures/isinstance.pyi]
597598

598-
[case testMemberAssignmentChanges-skip]
599+
[case testMemberAssignmentChanges]
599600
from typing import Union
600601

601602
class Dog:
602603
paws = 1 # type: Union[int, str]
603604

604605
pet = Dog()
605606

606-
pet.paws + 'a' # E: moo
607+
pet.paws + 'a' # E: Unsupported operand types for + ("int" and "str") \
608+
# N: Left operand is of type "Union[int, str]"
607609
pet.paws = 'a'
608610
pet.paws + 'a'
609611
pet.paws = 1
610612
pet.paws + 1
611613
[builtins fixtures/isinstancelist.pyi]
612614

613-
[case testIsInstanceSubClassMemberHard-skip]
615+
[case testIsInstanceSubClassMemberHard]
614616
from typing import Union
615617

616618
class Animal:
@@ -630,7 +632,9 @@ h.pet = Dog()
630632
if isinstance(h.pet, Dog):
631633
if isinstance(h.pet.paws, str):
632634
for i in [1]:
633-
h.pet.paws + 'a'
635+
# TODO: should we allow this if iterable is of length one or zero?
636+
h.pet.paws + 'a' # E: Unsupported operand types for + ("int" and "str") \
637+
# N: Left operand is of type "Union[int, str]"
634638
if bool():
635639
break
636640
h.pet.paws = 1
@@ -1314,7 +1318,7 @@ def f(x: Union[A, B]) -> None:
13141318
[builtins fixtures/isinstance.pyi]
13151319

13161320
[case testIsinstanceWithOverlappingPromotionTypes-skip]
1317-
# Currently disabled: see https://github.com/python/mypy/issues/6180 for context
1321+
# Currently disabled: see https://github.com/python/mypy/issues/6060 for context
13181322
from typing import Union
13191323

13201324
class FloatLike: pass

test-data/unit/check-literal.test

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3015,11 +3015,7 @@ expects_int(c)
30153015
expects_int(d) # E: Argument 1 to "expects_int" has incompatible type "Literal[D.FOO]"; expected "int"
30163016
[out]
30173017

3018-
[case testLiteralWithEnumsAliases-skip]
3019-
# TODO: Fix this test once https://github.com/python/mypy/issues/6667 is resolved.
3020-
#
3021-
# The linked issue is about nested classes, but the same root bug prevents aliases
3022-
# to enums from working.
3018+
[case testLiteralWithEnumsAliases]
30233019
from typing_extensions import Literal
30243020
from enum import Enum
30253021

test-data/unit/check-modules.test

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,10 @@ x = ''
568568
[file m2.py]
569569
x = 1
570570

571-
[case testStarImportOverridingLocalImports-skip]
571+
[case testStarImportOverridingLocalImports]
572572
from m1 import *
573573
from m2 import *
574-
x = '' # E: TODO (cannot assign str to int)
574+
x = '' # E: Incompatible types in assignment (expression has type "str", variable has type "int")
575575
[file m1.py]
576576
x = 1
577577
[file m2.py]
@@ -2240,9 +2240,7 @@ reveal_type(x) # N: Revealed type is 'builtins.str'
22402240
x = str()
22412241
y = int()
22422242

2243-
[case testForwardReferenceToListAlias-skip]
2244-
# TODO: This fails because of missing ImportedName handling in
2245-
# mypy.typeanal.TypeAnalyser.visit_unbound_type.
2243+
[case testForwardReferenceToListAlias]
22462244
x: List[int]
22472245
reveal_type(x) # N: Revealed type is 'builtins.list[builtins.int]'
22482246
def f() -> 'List[int]': pass
@@ -2391,16 +2389,15 @@ ignore_missing_imports = True
23912389
main:3: error: Cannot find implementation or library stub for module named 'a.b.d'
23922390
main:3: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
23932391

2394-
[case testIndirectFromImportWithinCycleUsedAsBaseClass-skip]
2395-
-- TODO: Fails because of missing ImportedName handling in mypy.typeanal
2392+
[case testIndirectFromImportWithinCycleUsedAsBaseClass]
23962393
import a
23972394
[file a.py]
23982395
from b import f
23992396
from c import B
24002397
[file b.py]
24012398
from c import y
24022399
class A(B): pass
2403-
reveal_type(A().x) # N: Revealed type is 'builtins.str'
2400+
reveal_type(A().x) # N: Revealed type is 'builtins.int'
24042401
from a import B
24052402
def f() -> None: pass
24062403
[file c.py]

test-data/unit/deps-expressions.test

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,14 @@ def f() -> int:
282282
<m.B.__new__> -> m.f
283283
<m.B> -> <m.A.__lt__>, m.A.__lt__, m.B, m.f
284284

285-
[case testIsOp-skip]
285+
[case testIsOp]
286286
class A: pass
287287
class B: pass
288288

289289
def f() -> bool:
290290
return A() is B()
291291
[builtins fixtures/bool.pyi]
292292
[out]
293-
-- fails because of https://github.com/python/mypy/issues/4055
294293
<m.A.__init__> -> m.f
295294
<m.A.__new__> -> m.f
296295
<m.A> -> m.A, m.f

test-data/unit/fine-grained.test

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,7 @@ class C:
590590
==
591591
a.py:2: error: Incompatible types in assignment (expression has type "str", variable has type "int")
592592

593-
[case testIgnoredAttrReprocessedModule-skip]
594-
# See https://github.com/python/mypy/issues/4782
593+
[case testIgnoredAttrReprocessedModule]
595594
import a
596595
[file a.py]
597596
import b
@@ -6860,7 +6859,7 @@ from typing import overload
68606859
==
68616860
main:3: error: Module has no attribute "f"
68626861

6863-
[case testOverloadsUpdatedTypeRecheckImplementation-skip]
6862+
[case testOverloadsUpdatedTypeRecheckImplementation]
68646863
from typing import overload
68656864
import mod
68666865
class Outer:

test-data/unit/parse-errors.test

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,17 @@ file:3: error: syntax error in type comment
273273
file:3: error: Inconsistent use of '*' in function signature
274274
file:3: error: Inconsistent use of '**' in function signature
275275

276-
[case testPrintStatementInPython3-skip]
276+
[case testPrintStatementInPython35]
277+
# flags: --python-version 3.5
277278
print 1
278279
[out]
279-
file:1: error: Missing parentheses in call to 'print'
280+
file:2: error: Missing parentheses in call to 'print'
281+
282+
[case testPrintStatementInPython37]
283+
# flags: --python-version 3.7
284+
print 1
285+
[out]
286+
file:2: error: Missing parentheses in call to 'print'. Did you mean print(1)?
280287

281288
[case testInvalidConditionInConditionalExpression]
282289
1 if 2, 3 else 4

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy