Skip to content

Commit d3b32b7

Browse files
emmatypingilevkivskyi
authored andcommitted
Use a shared incremental cache for pythoneval tests (#5114)
This causes the tests to run much faster! On my machine without incremental they take 52 seconds. With the incremental cache, they take only 22 seconds. This fixes #1412.
1 parent 7eebb8f commit d3b32b7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

mypy/test/testpythoneval.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import os.path
1515
import re
1616
import sys
17+
from tempfile import TemporaryDirectory
1718

1819
import pytest # type: ignore # no pytest in typeshed
1920

@@ -35,12 +36,13 @@ class PythonEvaluationSuite(DataSuite):
3536
files = ['pythoneval.test',
3637
'python2eval.test',
3738
'pythoneval-asyncio.test']
39+
cache_dir = TemporaryDirectory()
3840

3941
def run_case(self, testcase: DataDrivenTestCase) -> None:
40-
test_python_evaluation(testcase)
42+
test_python_evaluation(testcase, os.path.join(self.cache_dir.name, '.mypy_cache'))
4143

4244

43-
def test_python_evaluation(testcase: DataDrivenTestCase) -> None:
45+
def test_python_evaluation(testcase: DataDrivenTestCase, cache_dir: str) -> None:
4446
"""Runs Mypy in a subprocess.
4547
4648
If this passes without errors, executes the script again with a given Python
@@ -69,6 +71,7 @@ def test_python_evaluation(testcase: DataDrivenTestCase) -> None:
6971
with open(program_path, 'w') as file:
7072
for s in testcase.input:
7173
file.write('{}\n'.format(s))
74+
mypy_cmdline.append('--cache-dir={}'.format(cache_dir))
7275
output = []
7376
# Type check the program.
7477
out, err, returncode = api.run(mypy_cmdline)

0 commit comments

Comments
 (0)