Skip to content

Commit

Permalink
Remove some low-value, slow tests (#4874)
Browse files Browse the repository at this point in the history
The removed tests use real stubs and/or run Python and thus are pretty
slow to run. Most of them either test stubs in straightforward ways
(which is not very useful, since the coverage is bound to be spotty)
or some very basic functionality (which is covered by other tests).

The removals speed up the Python evaluation suite by about 25% on my
laptop (there is a high variance, though). There are probably others
that could safely be removed but I tried to be pretty conservative here.
  • Loading branch information
JukkaL authored Apr 9, 2018
1 parent f30f676 commit bba51e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 392 deletions.
81 changes: 1 addition & 80 deletions test-data/unit/python2eval.test
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ f(re.match('x*', 'xxy'))
[out]
xx

[case testVariableLengthTuple_python2]
from typing import Tuple, cast
x = cast(Tuple[int, ...], ())
print(x)
[out]
()

[case testFromFuturePrintFunction_python2]
from __future__ import print_function
print('a', 'b')
Expand Down Expand Up @@ -162,15 +155,13 @@ _program.py:5: error: Argument 1 to "f" has incompatible type "unicode"; expecte
_program.py:6: error: Argument 1 to "f" has incompatible type "unicode"; expected "str"

[case testStrUnicodeCompatibility_python2]
import typing
def f(s): # type: (unicode) -> None
pass
f(u'')
f('')
[out]

[case testStrUnicodeCompatibilityInBuiltins_python2]
import typing
'x'.count('x')
'x'.count(u'x')
[out]
Expand All @@ -184,16 +175,6 @@ f(tuple())
[out]
()

[case testReadOnlyProperty_python2]
import typing
class A:
@property
def foo(self): # type: () -> int
return 1
print(A().foo + 2)
[out]
3

[case testIOTypes_python2]
from typing import IO, TextIO, BinaryIO, Any
class X(IO[str]): pass
Expand Down Expand Up @@ -259,19 +240,6 @@ print 'ok'
[out]
ok

[case testUnionType_python2]
from typing import Union
y = None # type: Union[int, str]
def f(x): # type: (Union[int, str]) -> str
if isinstance(x, int):
x = str(x)
return x
print f(12)
print f('ab')
[out]
12
ab

[case testStrAdd_python2]
import typing
s = ''
Expand All @@ -294,21 +262,13 @@ s = ''.join([u'']) # Error
_program.py:5: error: Incompatible types in assignment (expression has type "str", variable has type "int")
_program.py:6: error: Incompatible types in assignment (expression has type "unicode", variable has type "str")

[case testNamedTuple_python2]
import typing
from collections import namedtuple
X = namedtuple('X', ['a', 'b'])
x = X(a=1, b='s')
print x.a, x.b
[out]
1 s

[case testNamedTupleError_python2]
import typing
from collections import namedtuple
X = namedtuple('X', ['a', 'b'])
x = X(a=1, b='s')
x.c
x.a
[out]
_program.py:5: error: "X" has no attribute "c"

Expand All @@ -332,27 +292,6 @@ print 4j / 2.0
6j
2j

[case testNamedTupleWithTypes_python2]
from typing import NamedTuple
N = NamedTuple('N', [('a', int), ('b', str)])
n = N(1, 'x')
print n
a, b = n
print a, b
print n[0]
[out]
N(a=1, b='x')
1 x
1

[case testUnionTypeAlias_python2]
from typing import Union
U = Union[int, str]
u = 1 # type: U
u = 1.1
[out]
_program.py:4: error: Incompatible types in assignment (expression has type "float", variable has type "Union[int, str]")

[case testSuperNew_python2]
from typing import Dict, Any
class MyType(type):
Expand All @@ -365,24 +304,6 @@ print(type(A()).__name__)
[out]
Ax

[case testSequenceIndexAndCount_python2]
from typing import Sequence
def f(x): # type: (Sequence[int]) -> None
print(x.index(1))
print(x.count(1))
f([0, 0, 1, 1, 1])
[out]
2
3

[case testOptional_python2]
from typing import Optional
def f(): # type: () -> Optional[int]
pass
x = f()
y = 1
y = x

[case testUnicodeAndOverloading_python2]
from m import f
f(1)
Expand Down
Loading

0 comments on commit bba51e0

Please sign in to comment.