Skip to content
Snippets Groups Projects
Commit f80097ba authored by Carsten Schoenert's avatar Carsten Schoenert
Browse files

New upstream version 0.14.0

parent 505c97ef
No related branches found
No related tags found
No related merge requests found
Showing
with 149 additions and 49 deletions
......@@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', pypy3.8, pypy3.9, pypy3.10]
os: [ubuntu-latest, windows-latest, macos-13]
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
......
......@@ -3,26 +3,22 @@ on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
workflow_dispatch:
jobs:
build:
name: Deploy docs
name: Deploy docs for new version
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- run: pip install hatch
- run: hatch run docs:export-deps > doc_requirements.txt
- name: Deploy docs
uses: mhausenblas/mkdocs-deploy-gh-pages@d77dd03172e96abbcdb081d8c948224762033653 # 1.26
# Or use mhausenblas/mkdocs-deploy-gh-pages@nomaterial to build without the mkdocs-material theme
- run: hatch version | sed -rne "s:([0-9]*)\.([0-9]*)\..*:INLINE_SNAPSHOT_VERSION=\1.\2:p" >> ${GITHUB_ENV}
- name: publish docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#CUSTOM_DOMAIN: optionaldomain.com
#CONFIG_FILE: folder/mkdocs.yml
#EXTRA_PACKAGES: build-base
# GITHUB_DOMAIN: github.myenterprise.com
REQUIREMENTS: doc_requirements.txt
run: |
git config user.name "Frank Hoffmann"
git config user.email "15r10nk@users.noreply.github.com"
git fetch origin gh-pages --depth=1
hatch run docs:mike deploy --push ${INLINE_SNAPSHOT_VERSION} latest
......@@ -6,13 +6,18 @@ on:
jobs:
build:
name: build docs
name: Deploy development docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: '3.12'
architecture: x64
- name: Checkout main
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- run: pip install hatch
- run: hatch run docs:build
- name: publish docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "Frank Hoffmann"
git config user.email "15r10nk@users.noreply.github.com"
git fetch origin gh-pages --depth=1
hatch run docs:mike deploy --push development
......@@ -69,10 +69,10 @@ repos:
rev: v3.28.0
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
hooks:
- id: docformatter
# - repo: https://github.com/PyCQA/docformatter
# rev: v1.7.5
# hooks:
# - id: docformatter
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.18
......
<a id='changelog-0.14.0'></a>
# 0.14.0 — 2024-11-10
## Removed
- removed the `"Programming Language :: Python :: Implementation :: PyPy"` classifier which was incorrect, because inline-snapshot can not fix snapshots on pypy.
inline-snapshot now enforces `--inline-snapshot=disable` when used with an implementation other than cpython, which allows it to be used in packages that want to support pypy.
## Added
- command line shortcuts can be defined to simplify your workflows. `--review` and `--fix` are defined by default. See the [documentation](https://15r10nk.github.io/inline-snapshot/configuration/) for details.
## Changed
- `--inline-snapshot=create/fix/trim/update` will no longer show reports for other categories.
You can use `--inline-snapshot=create,report` if you want to use the old behaviour.
<a id='changelog-0.13.4'></a>
# 0.13.4 — 2024-11-07
## Changed
- use tomli instead of toml (#130)
<a id='changelog-0.13.3'></a>
# 0.13.3 — 2024-09-24
......
......@@ -169,7 +169,7 @@ I would like to thank my sponsors. Without them, I would not be able to invest s
### Bronze sponsor 🥉
<p align="center">
<a href="https://pydantic.dev/">
<a href="https://pydantic.dev/logfire">
<img src="docs/assets/sponsors/pydantic.png" alt="pydantic" width="300"/>
</a>
</p>
......
docs/assets/sponsors/pydantic.png

15.9 KiB | W: | H:

docs/assets/sponsors/pydantic.png

207 KiB | W: | H:

docs/assets/sponsors/pydantic.png
docs/assets/sponsors/pydantic.png
docs/assets/sponsors/pydantic.png
docs/assets/sponsors/pydantic.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -58,7 +58,7 @@ The result of each comparison is `True` if you change something from this catego
<div class="grid" markdown>
<!-- inline-snapshot: first_block outcome-failed=1 -->
<!-- inline-snapshot: first_block outcome-failed=1 outcome-errors=1 -->
``` python
def test_something():
assert 8 == snapshot(5)
......
Default configuration:
``` toml
[tool.inline-snapshot]
hash-length=15
default-flags=["short-report"]
[tool.inline-snapshot.shortcuts]
review=["review"]
fix=["create","fix"]
```
* *hash-length:* specifies the length of the hash used by `external()` in the code representation.
* **hash-length:** specifies the length of the hash used by `external()` in the code representation.
This does not affect the hash length used to store the data.
The hash should be long enough to avoid hash collisions.
* *default-flags:* defines which flags should be used if there are no flags specified with `--inline-snapshot=...`.
* **default-flags:** defines which flags should be used if there are no flags specified with `--inline-snapshot=...`.
You can also use the environment variable `INLINE_SNAPSHOT_DEFAULT_FLAGS=...` to specify the flags and to override those in the configuration file.
* **shortcuts:** allows you to define custom commands to simplify your workflows.
`--fix` and `--review` are defined by default, but this configuration can be changed to fit your needs.
......@@ -21,7 +21,7 @@ Example:
```
=== "value changed"
<!-- inline-snapshot: outcome-failed=1 -->
<!-- inline-snapshot: outcome-failed=1 outcome-errors=1 -->
``` python hl_lines="2"
def test_something():
assert 2 + 40 == snapshot(4)
......@@ -111,7 +111,7 @@ Example:
```
=== "changed payload"
<!-- inline-snapshot: outcome-failed=1 -->
<!-- inline-snapshot: outcome-failed=1 outcome-errors=1 -->
``` python hl_lines="9"
from inline_snapshot import snapshot
from dirty_equals import IsDatetime
......
......@@ -55,7 +55,7 @@ Maybe that is correct and you should fix your code, or
your code is correct and you want to update your test results.
=== "changed code"
<!-- inline-snapshot: outcome-failed=1 -->
<!-- inline-snapshot: outcome-failed=1 outcome-errors=1 -->
``` python hl_lines="2"
def something():
return (1548 * 18489) // 18
......
## pytest assert rewriting is disabled
inline-snapshot must disable pytest assert-rewriting if you use report/review/create/fix/trim/update flags.
## xdist is not supported
You can not use inline-snapshot in combination with `pytest-xdist`. The use of `-n=...` implies `--inline-snapshot=disable`.
## works only with cpython
inline-snapshot works currently only with cpython. `--inline-snapshot=disable` is enforced for every other implementation.
......@@ -59,7 +59,7 @@ The following example shows how you can use the `Example` class to test what inl
report=snapshot(
"""\
Error: one snapshot is missing a value (--inline-snapshot=create)
You can also use --inline-snapshot=review to approve the changes interactiv\
You can also use --inline-snapshot=review to approve the changes interactively\
"""
),
).run_pytest( # run with create flag and check the changed files
......
{% extends "base.html" %}
{% block outdated %}
You're not viewing the latest version.
<a href="{{ '../' ~ base_url }}">
<strong>Click here to go to latest.</strong>
</a>
{% endblock %}
{% block announce %}
{{ super() }}
......
......@@ -46,6 +46,7 @@ nav:
- Configuration: configuration.md
- Code generation: code_generation.md
- Testing: testing.md
- Limitations: limitations.md
- Contributing: contributing.md
- Changelog: changelog.md
......@@ -80,9 +81,15 @@ plugins:
ansi: required
- replace-url
extra:
social:
- icon: fontawesome/brands/x-twitter
link: https://x.com/15r10nk
- icon: fontawesome/brands/mastodon
link: https://fosstodon.org/@15r10nk
version:
provider: mike
default:
- latest
- development
......@@ -29,8 +29,7 @@ dependencies = [
"click>=8.1.4",
"executing>=2.1.0",
"rich>=13.7.1",
"toml>=0.10.2; python_version < '3.11'",
"types-toml>=0.10.8.7; python_version < '3.11'",
"tomli>=2.0.0; python_version < '3.11'",
"typing-extensions"
]
description = "golden master/snapshot/approval testing library which puts the values right into your source code"
......@@ -38,7 +37,7 @@ keywords = []
name = "inline-snapshot"
readme = "README.md"
requires-python = ">=3.8"
version = "0.13.3"
version = "0.14.0"
[project.entry-points.pytest11]
inline_snapshot = "inline_snapshot.pytest_plugin"
......@@ -88,6 +87,7 @@ dependencies = [
"markdown-exec[ansi]>=1.8.0",
"mkdocs>=1.4.2",
"mkdocs-material[imaging]>=9.5.17",
"mike",
"mkdocstrings[python]>=0.19.0",
"replace-url @ {root:uri}/docs/plugins",
"pytest",
......@@ -105,7 +105,7 @@ dependencies=["cogapp","lxml","requests"]
scripts.update="cog -r docs/**.md"
[[tool.hatch.envs.hatch-test.matrix]]
python = ["3.13", "3.12", "3.11", "3.10", "3.9", "3.8"]
python = ["3.13", "3.12", "3.11", "3.10", "3.9", "3.8","pypy3.8","pypy3.9","pypy3.10"]
[tool.hatch.envs.hatch-test]
extra-dependencies = [
......@@ -114,7 +114,7 @@ extra-dependencies = [
"mypy>=1.2.0",
"pyright>=1.1.359",
"pytest-subtests>=0.11.0",
"time-machine>=2.10.0",
"pytest-freezer>=0.4.8",
"pydantic"
]
env-vars.TOP = "{root}"
......@@ -127,6 +127,25 @@ extra-dependencies = [
"pydantic"
]
[tool.hatch.envs.release]
detached=true
dependencies=[
"scriv",
"commitizen"
]
[tool.hatch.envs.release.scripts]
create=[
"scriv collect",
"cz bump"
]
publish=[
"git push --force-with-lease",
"git push --tags",
"rm dist/*",
"hatch build",
"hatch publish"
]
[[tool.hatch.envs.types.matrix]]
python = ["3.8", "3.9", "3.10", "3.11", "3.12","3.13"]
......@@ -143,4 +162,8 @@ venvPath = ".nox"
[tool.scriv]
format = "md"
version = "literal: pyproject.toml: project.version"
version = "command: cz bump --get-next"
[tool.inline-snapshot.shortcuts]
sfix="create,fix"
review="create,review"
......@@ -8,4 +8,4 @@ from ._types import Snapshot
__all__ = ["snapshot", "external", "outsource", "customize_repr", "HasRepr"]
__version__ = "0.13.3"
__version__ = "0.14.0"
......@@ -3,18 +3,21 @@ import sys
from dataclasses import dataclass
from dataclasses import field
from pathlib import Path
from typing import Dict
from typing import List
if sys.version_info >= (3, 11):
from tomllib import loads
else:
from toml import loads
from tomli import loads
@dataclass
class Config:
hash_length: int = 12
default_flags: List[str] = field(default_factory=lambda: ["short-report"])
shortcuts: Dict[str, List[str]] = field(default_factory=dict)
config = Config()
......@@ -35,11 +38,16 @@ def read_config(path: Path) -> Config:
result.hash_length = config["hash-length"]
except KeyError:
pass
try:
result.default_flags = config["default-flags"]
except KeyError:
pass
result.shortcuts = config.get(
"shortcuts", {"fix": ["create", "fix"], "review": ["review"]}
)
env_var = "INLINE_SNAPSHOT_DEFAULT_FLAGS"
if env_var in os.environ:
result.default_flags = os.environ[env_var].split(",")
......
......@@ -44,6 +44,14 @@ _active = False
_files_with_snapshots: Set[str] = set()
_missing_values = 0
_incorrect_values = 0
def _return(result):
global _incorrect_values
if not result:
_incorrect_values += 1
return result
class InlineSnapshotSyntaxWarning(Warning):
......@@ -328,8 +336,11 @@ class EqValue(GenericValue):
if self._new_value is undefined:
self._new_value = use_valid_old_values(self._old_value, clone(other))
return self._visible_value() == other
if self._old_value is undefined or ignore_old_value():
return True
return _return(self._old_value == other)
else:
return _return(self._new_value == other)
def _new_code(self):
return self._value_to_code(self._new_value)
......@@ -514,12 +525,14 @@ class MinMaxValue(GenericValue):
if self._new_value is undefined:
self._new_value = clone(other)
if self._old_value is undefined or ignore_old_value():
return True
return _return(self.cmp(self._old_value, other))
else:
self._new_value = (
self._new_value if self.cmp(self._new_value, other) else clone(other)
)
if not self.cmp(self._new_value, other):
self._new_value = clone(other)
return self.cmp(self._visible_value(), other)
return _return(self.cmp(self._visible_value(), other))
def _new_code(self):
return self._value_to_code(self._new_value)
......@@ -609,7 +622,7 @@ class CollectionValue(GenericValue):
if ignore_old_value() or self._old_value is undefined:
return True
else:
return item in self._old_value
return _return(item in self._old_value)
def _new_code(self):
return self._value_to_code(self._new_value)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment