Skip to content

Commit 0ef41f3

Browse files
author
Guido van Rossum
committed
Moar tests
1 parent c741333 commit 0ef41f3

File tree

2 files changed

+121
-2
lines changed

2 files changed

+121
-2
lines changed

mypy/test/testcheck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def parse_module(self, program_text: str, incremental: int = 0) -> List[Tuple[st
308308
def parse_options(self, program_text: str, testcase: DataDrivenTestCase,
309309
incremental: int) -> Options:
310310
options = Options()
311-
flags = re.search('# flags1?: (.*)$', program_text, flags=re.MULTILINE)
311+
flags = re.search('# flags: (.*)$', program_text, flags=re.MULTILINE)
312312
if incremental == 2:
313313
flags2 = re.search('# flags2: (.*)$', program_text, flags=re.MULTILINE)
314314
if flags2:

test-data/unit/check-incremental.test

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@
55
-- Errors expected in the first run should be in the `[out1]` section, and
66
-- errors expected in the second run should be in the `[out2]` section. If a
77
-- section is omitted, it is expected there are no errors on that run.
8+
-- (Note that [out] is equivalent to [out1].)
89
--
9-
-- As always, extra flags may be specified using
10+
-- The list of modules to be checked can be specified using
11+
-- # cmd: mypy -m mod1 mod2 mod3
12+
-- To check a different list on the second run, use
13+
-- # cmd2: mypy -m mod1 mod3
14+
--
15+
-- Extra command line flags may be specified using
1016
-- # flags: --some-flag
1117
-- If the second run requires different flags, those can be specified using
1218
-- # flags2: --another-flag
@@ -1924,3 +1930,116 @@ tmp/a.py:2: error: Incompatible return value type (got "str", expected "int")
19241930
[out2]
19251931
[rechecked a]
19261932
[stale a]
1933+
1934+
[case testQuickAndDirty5]
1935+
# flags: --quick-and-dirty
1936+
import a, b
1937+
[file a.py]
1938+
import b
1939+
[file b.py]
1940+
import a
1941+
[file a.py.next]
1942+
import b
1943+
def foo() -> int: return ''
1944+
[out1]
1945+
[out2]
1946+
tmp/a.py:2: error: Incompatible return value type (got "str", expected "int")
1947+
[rechecked a]
1948+
[stale]
1949+
1950+
[case testQuickAndDirty6]
1951+
# flags: --quick-and-dirty
1952+
import a, b
1953+
[file a.py]
1954+
import b
1955+
def foo() -> int: return ''
1956+
[file b.py]
1957+
import a
1958+
[file a.py.next]
1959+
import b
1960+
def foo() -> int: return 0.5
1961+
[out1]
1962+
tmp/a.py:2: error: Incompatible return value type (got "str", expected "int")
1963+
[out2]
1964+
tmp/a.py:2: error: Incompatible return value type (got "float", expected "int")
1965+
[rechecked a]
1966+
[stale]
1967+
1968+
[case testQuickAndDirty7]
1969+
# flags: --quick-and-dirty
1970+
import a, b
1971+
[file a.py]
1972+
import b
1973+
[file b.py]
1974+
import a
1975+
class C: pass
1976+
def f() -> int: pass
1977+
[file a.py.next]
1978+
import b
1979+
reveal_type(b.C)
1980+
reveal_type(b.f)
1981+
[out1]
1982+
[out2]
1983+
tmp/a.py:2: error: Revealed type is 'def () -> b.C'
1984+
tmp/a.py:3: error: Revealed type is 'def () -> builtins.int'
1985+
[rechecked a]
1986+
[stale]
1987+
1988+
[case testQuickAndDirty8]
1989+
# flags: --quick-and-dirty
1990+
import a, b
1991+
[file a.py]
1992+
import b
1993+
class C: pass
1994+
def f() -> int: pass
1995+
[file b.py]
1996+
import a
1997+
[file b.py.next]
1998+
import a
1999+
reveal_type(a.C)
2000+
reveal_type(a.f)
2001+
[out1]
2002+
[out2]
2003+
tmp/b.py:2: error: Revealed type is 'def () -> a.C'
2004+
tmp/b.py:3: error: Revealed type is 'def () -> builtins.int'
2005+
[rechecked b]
2006+
[stale]
2007+
2008+
-- (The behavior for blockers is actually no different than in regular incremental mode)
2009+
[case testQuickAndDirty9]
2010+
# noflags: --quick-and-dirty
2011+
import a, b
2012+
[file a.py]
2013+
import b
2014+
class B: pass
2015+
class C(B, B): pass # blocker
2016+
[file b.py]
2017+
import a
2018+
[file a.py.next]
2019+
import b
2020+
class B: pass
2021+
class C(B): pass
2022+
[out1]
2023+
tmp/a.py:3: error: Duplicate base class "B"
2024+
[out2]
2025+
[rechecked a, b]
2026+
[stale a, b]
2027+
2028+
[case testQuickAndDirty10]
2029+
# noflags: --quick-and-dirty
2030+
import a, b
2031+
[file a.py]
2032+
import b
2033+
class B: pass
2034+
class C(B): pass
2035+
[file b.py]
2036+
import a
2037+
[file a.py.next]
2038+
import b
2039+
class B: pass
2040+
class C(B, B): pass # blocker
2041+
[out1]
2042+
[out2]
2043+
tmp/a.py:3: error: Duplicate base class "B"
2044+
[rechecked a, b]
2045+
[stale a, b]

0 commit comments

Comments
 (0)