Skip to content

Commit

Permalink
feat!: removed old --update-snapshots option
Browse files Browse the repository at this point in the history
  • Loading branch information
15r10nk committed Feb 27, 2024
1 parent 428678a commit 479b66f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 51 deletions.
30 changes: 0 additions & 30 deletions inline_snapshot/pytest_plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import argparse
from pathlib import Path

import pytest
Expand Down Expand Up @@ -34,16 +33,6 @@ def pytest_addoption(parser):
help="disable snapshot logic",
)

# deprecated option
group.addoption(
"--update-snapshots",
action="store",
dest="inline_snapshot_deprecated",
default="none",
choices=("all", "failing", "new", "none"),
help=argparse.SUPPRESS,
)


def pytest_configure(config):
flags = config.option.inline_snapshot.split(",")
Expand All @@ -58,30 +47,11 @@ def pytest_configure(config):

_inline_snapshot._update_flags = _inline_snapshot.Flags(set(flags))

old_flag = config.option.inline_snapshot_deprecated

snapshot_path = Path(config.rootpath) / ".inline-snapshot/external"
_external.storage = _external.DiscStorage(snapshot_path)

_config.config = _config.read_config(config.rootpath / "pyproject.toml")

if old_flag != "none":
msg_prefix = f"--update-snapshots={old_flag} is deprecated, please use "

if _inline_snapshot._update_flags.change_something():
raise pytest.UsageError(msg_prefix + "only --inline-snapshot")

elif old_flag == "failing":
raise pytest.UsageError(msg_prefix + "--inline-snapshot=fix")

elif old_flag == "new":
raise pytest.UsageError(msg_prefix + "--inline-snapshot=create")

elif old_flag == "all":
raise pytest.UsageError(msg_prefix + "--inline-snapshot=create,fix")
else:
assert False

if _inline_snapshot._update_flags.change_something():
import sys

Expand Down
22 changes: 1 addition & 21 deletions tests/test_pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,39 +163,19 @@ def test_a():
)


def test_deprecated_option(project):
def test_disable_option(project):
project.setup(
"""\
def test_a():
pass
"""
)

result = project.run("--update-snapshots=failing")
assert result.stderr.str().strip() == snapshot(
"ERROR: --update-snapshots=failing is deprecated, please use --inline-snapshot=fix"
)

result = project.run("--update-snapshots=new")
assert result.stderr.str().strip() == snapshot(
"ERROR: --update-snapshots=new is deprecated, please use --inline-snapshot=create"
)

result = project.run("--update-snapshots=all")
assert result.stderr.str().strip() == snapshot(
"ERROR: --update-snapshots=all is deprecated, please use --inline-snapshot=create,fix"
)

result = project.run("--inline-snapshot-disable", "--inline-snapshot=fix")
assert result.stderr.str().strip() == snapshot(
"ERROR: --inline-snapshot-disable can not be combined with other flags (fix)"
)

result = project.run("--update-snapshots=failing", "--inline-snapshot=fix")
assert result.stderr.str().strip() == snapshot(
"ERROR: --update-snapshots=failing is deprecated, please use only --inline-snapshot"
)


def test_black_config(project):
project.setup(
Expand Down

0 comments on commit 479b66f

Please sign in to comment.