1818from .._core ._tests .tutil import slow
1919from .pytest_plugin import RUN_SLOW
2020
21+ mypy_cache_updated = False
22+
2123
2224def test_core_is_properly_reexported ():
2325 # Each export from _core should be re-exported by exactly one of these
@@ -72,6 +74,7 @@ def public_modules(module):
7274 "ignore:module 'sre_constants' is deprecated:DeprecationWarning" ,
7375)
7476def test_static_tool_sees_all_symbols (tool , modname , tmpdir ):
77+ global mypy_cache_updated
7578 module = importlib .import_module (modname )
7679
7780 def no_underscores (symbols ):
@@ -113,7 +116,16 @@ def no_underscores(symbols):
113116 from mypy .api import run
114117
115118 # This pollutes the `empty` dir. Should this be changed?
116- run (["--config-file=" , "--cache-dir=./.mypy_cache" , "-c" , f"import { modname } " ])
119+ if not mypy_cache_updated :
120+ run (
121+ [
122+ "--config-file=" ,
123+ "--cache-dir=./.mypy_cache" ,
124+ "-c" ,
125+ f"import { modname } " ,
126+ ]
127+ )
128+ mypy_cache_updated = True
117129
118130 trio_cache = next (cache .glob ("*/trio" ))
119131 _ , modname = (modname + "." ).split ("." , 1 )
@@ -197,6 +209,7 @@ def no_underscores(symbols):
197209@pytest .mark .parametrize ("module_name" , PUBLIC_MODULE_NAMES )
198210@pytest .mark .parametrize ("tool" , ["jedi" , "mypy" ])
199211def test_static_tool_sees_class_members (tool , module_name , tmpdir ) -> None :
212+ global mypy_cache_updated
200213 module = PUBLIC_MODULES [PUBLIC_MODULE_NAMES .index (module_name )]
201214
202215 # ignore hidden, but not dunder, symbols
@@ -222,14 +235,16 @@ def no_hidden(symbols):
222235 from mypy .api import run
223236
224237 # This pollutes the `empty` dir. Should this be changed?
225- run (
226- [
227- "--config-file=" ,
228- "--cache-dir=./.mypy_cache" ,
229- "-c" ,
230- f"import { module_name } " ,
231- ]
232- )
238+ if not mypy_cache_updated :
239+ run (
240+ [
241+ "--config-file=" ,
242+ "--cache-dir=./.mypy_cache" ,
243+ "-c" ,
244+ f"import { module_name } " ,
245+ ]
246+ )
247+ mypy_cache_updated = False
233248
234249 trio_cache = next (cache .glob ("*/trio" ))
235250 modname = module_name
0 commit comments