Skip to content

Commit

Permalink
Only make sure mypy cache is up to date once
Browse files Browse the repository at this point in the history
  • Loading branch information
A5rocks committed Jun 23, 2023
1 parent 2242e0f commit 1f75b1f
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions trio/_tests/test_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from .._core._tests.tutil import slow
from .pytest_plugin import RUN_SLOW

mypy_cache_updated = False


def test_core_is_properly_reexported():
# Each export from _core should be re-exported by exactly one of these
Expand Down Expand Up @@ -72,6 +74,7 @@ def public_modules(module):
"ignore:module 'sre_constants' is deprecated:DeprecationWarning",
)
def test_static_tool_sees_all_symbols(tool, modname, tmpdir):
global mypy_cache_updated
module = importlib.import_module(modname)

def no_underscores(symbols):
Expand Down Expand Up @@ -113,7 +116,16 @@ def no_underscores(symbols):
from mypy.api import run

# This pollutes the `empty` dir. Should this be changed?
run(["--config-file=", "--cache-dir=./.mypy_cache", "-c", f"import {modname}"])
if not mypy_cache_updated:
run(
[
"--config-file=",
"--cache-dir=./.mypy_cache",
"-c",
f"import {modname}",
]
)
mypy_cache_updated = True

trio_cache = next(cache.glob("*/trio"))
_, modname = (modname + ".").split(".", 1)
Expand Down Expand Up @@ -197,6 +209,7 @@ def no_underscores(symbols):
@pytest.mark.parametrize("module_name", PUBLIC_MODULE_NAMES)
@pytest.mark.parametrize("tool", ["jedi", "mypy"])
def test_static_tool_sees_class_members(tool, module_name, tmpdir) -> None:
global mypy_cache_updated
module = PUBLIC_MODULES[PUBLIC_MODULE_NAMES.index(module_name)]

# ignore hidden, but not dunder, symbols
Expand All @@ -222,14 +235,16 @@ def no_hidden(symbols):
from mypy.api import run

# This pollutes the `empty` dir. Should this be changed?
run(
[
"--config-file=",
"--cache-dir=./.mypy_cache",
"-c",
f"import {module_name}",
]
)
if not mypy_cache_updated:
run(
[
"--config-file=",
"--cache-dir=./.mypy_cache",
"-c",
f"import {module_name}",
]
)
mypy_cache_updated = False

trio_cache = next(cache.glob("*/trio"))
modname = module_name
Expand Down

0 comments on commit 1f75b1f

Please sign in to comment.