diff --git a/src/inline_snapshot/pytest_plugin.py b/src/inline_snapshot/pytest_plugin.py index 7c8c165..c164d4e 100644 --- a/src/inline_snapshot/pytest_plugin.py +++ b/src/inline_snapshot/pytest_plugin.py @@ -4,6 +4,7 @@ from pathlib import Path import pytest +from inline_snapshot.testing._example import init_env from rich import box from rich.console import Console from rich.panel import Panel @@ -54,6 +55,8 @@ def xdist_running(config): def pytest_configure(config): global flags + init_env() + _config.config = _config.read_config(config.rootpath / "pyproject.toml") if config.option.inline_snapshot is None: diff --git a/src/inline_snapshot/testing/_example.py b/src/inline_snapshot/testing/_example.py index 59d2d29..7a8926f 100644 --- a/src/inline_snapshot/testing/_example.py +++ b/src/inline_snapshot/testing/_example.py @@ -22,6 +22,17 @@ from .._types import Snapshot +def init_env(): + import inline_snapshot._inline_snapshot as inline_snapshot + + inline_snapshot.snapshots = {} + inline_snapshot._update_flags = inline_snapshot.Flags() + inline_snapshot._active = True + external.storage = None + inline_snapshot._files_with_snapshots = set() + inline_snapshot._missing_values = 0 + + @contextlib.contextmanager def snapshot_env(): import inline_snapshot._inline_snapshot as inline_snapshot diff --git a/tests/test_typing.py b/tests/test_typing.py deleted file mode 100644 index f43efc1..0000000 --- a/tests/test_typing.py +++ /dev/null @@ -1,40 +0,0 @@ -import sys - -import pytest - - -@pytest.fixture(params=["mypy", "pyright"]) -def check_typing(pytester, request): - prog = request.param - - def f(code): - pytester.makefile(".py", test_something=code) - pytester.makefile( - ".toml", - pyproject=""" - -[tool.pyright] -typeCheckingMode = 'strict' - -[tool.mypy] -strict=true - - """, - ) - - result = pytester.run(sys.executable, "-m", prog, "test_something.py") - - print(result.stdout) - assert result.ret == 0 - - yield f - - -def test_typing(check_typing): - check_typing( - """ -from inline_snapshot import snapshot -snapshot([]) -snapshot({}) - """ - )