Skip to content

Commit d0b9253

Browse files
committed
More stub tests
1 parent 0df5b9a commit d0b9253

File tree

2 files changed

+41
-14
lines changed

2 files changed

+41
-14
lines changed

tests/test_stubs.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
import subprocess
66
import sys
77

8-
from typing import Tuple, List, Dict, Set
9-
10-
from mypy.test.data import parse_test_cases, DataDrivenTestCase, DataSuite
8+
from mypy.test.data import parse_test_cases, DataSuite
119
from mypy.test.helpers import (assert_string_arrays_equal,
1210
normalize_error_messages)
1311

@@ -21,18 +19,18 @@
2119
class PythonEvaluationSuite(DataSuite):
2220

2321
@classmethod
24-
def cases(cls) -> List[DataDrivenTestCase]:
22+
def cases(cls):
2523
return parse_test_cases(test_file,
2624
_test_python_evaluation,
2725
base_path=test_temp_dir,
2826
optional_out=True,
2927
native_sep=True)
3028

31-
def run_case(self, testcase: DataDrivenTestCase):
29+
def run_case(self, testcase):
3230
_test_python_evaluation(testcase)
3331

3432

35-
def _test_python_evaluation(testcase: DataDrivenTestCase) -> None:
33+
def _test_python_evaluation(testcase):
3634
assert testcase.old_cwd is not None, "test was not properly set up"
3735
# Write the program to a file.
3836
program = '_program.py'
@@ -61,7 +59,7 @@ def _test_python_evaluation(testcase: DataDrivenTestCase) -> None:
6159
testcase.file, testcase.line))
6260

6361

64-
def parse_args(line: str) -> List[str]:
62+
def parse_args(line):
6563
"""Parse the first line of the program for the command line.
6664
6765
This should have the form

tests/test_stubs.test

+36-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,49 @@
1-
[case test_type_annotations]
1+
[case test_type_annotations_pep526]
22
# cmd: mypy a.py
33
[file a.py]
44
import attr
55

66
@attr.s
77
class C(object):
88
a : int = attr.ib()
9-
b = attr.ib(type=int)
109

1110
c = C()
1211
reveal_type(c.a)
13-
reveal_type(c.b)
1412
reveal_type(C.a)
15-
reveal_type(C.b)
1613
[out]
14+
a.py:8: error: Revealed type is 'builtins.int'
1715
a.py:9: error: Revealed type is 'builtins.int'
18-
a.py:10: error: Revealed type is 'builtins.int'
19-
a.py:11: error: Revealed type is 'builtins.int'
20-
a.py:12: error: Revealed type is 'builtins.int'
16+
17+
18+
[case test_type_annotations_arg]
19+
# cmd: mypy a.py
20+
[file a.py]
21+
import attr
22+
23+
@attr.s
24+
class C(object):
25+
a = attr.ib(type=int)
26+
27+
c = C()
28+
reveal_type(c.a)
29+
reveal_type(C.a)
30+
[out]
31+
a.py:8: error: Revealed type is 'builtins.int*'
32+
a.py:9: error: Revealed type is 'builtins.int*'
33+
34+
35+
[case test_type_annotations_missing]
36+
# cmd: mypy a.py
37+
[file a.py]
38+
import attr
39+
40+
@attr.s
41+
class C(object):
42+
a = attr.ib()
43+
44+
c = C()
45+
reveal_type(c.a)
46+
reveal_type(C.a)
47+
[out]
48+
a.py:8: error: Revealed type is 'Any'
49+
a.py:9: error: Revealed type is 'Any'

0 commit comments

Comments
 (0)