Skip to content

Commit

Permalink
snapshots inside tests which are marked as xfail are now ignored (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
15r10nk committed Feb 2, 2025
1 parent 13b9e50 commit 2562896
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelog.d/20250202_081752_15r10nk-git_new_defaults.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Fixed

- snapshots inside tests which are marked as xfail are now ignored (#184)
12 changes: 10 additions & 2 deletions src/inline_snapshot/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from ._code_repr import used_hasrepr
from ._find_external import ensure_import
from ._flags import Flags
from ._global_state import snapshot_env
from ._global_state import state
from ._inline_snapshot import used_externals
from ._rewrite_code import ChangeRecorder
Expand Down Expand Up @@ -145,10 +146,17 @@ def pytest_configure(config):


@pytest.fixture(autouse=True)
def snapshot_check():
def snapshot_check(request):
state().missing_values = 0
state().incorrect_values = 0
yield

if "xfail" in request.keywords:
with snapshot_env() as local_state:
local_state.active = False
yield
return
else:
yield

missing_values = state().missing_values
incorrect_values = state().incorrect_values
Expand Down

0 comments on commit 2562896

Please sign in to comment.