Skip to content

Commit

Permalink
Merge pull request #55 from 15r10nk/remove-deprecated-option
Browse files Browse the repository at this point in the history
feat!: removed old --update-snapshots option
  • Loading branch information
15r10nk authored Feb 27, 2024
2 parents 428678a + 80ef069 commit 6ba0243
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 53 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v0.7.0 (2024-02-27)

### Feat

- removed old --update-snapshots option

## v0.6.1 (2024-01-28)

### Fix
Expand Down
2 changes: 1 addition & 1 deletion inline_snapshot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

__all__ = ["snapshot", "external", "outsource"]

__version__ = "0.6.1"
__version__ = "0.7.0"
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ license = "MIT"
name = "inline-snapshot"
readme = "README.md"
repository = "https://github.com/15r10nk/inline-snapshots"
version = "0.6.1"
version = "0.7.0"

[tool.poetry.dependencies]
asttokens = ">=2.0.5"
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 6ba0243

Please sign in to comment.