pax_global_header 0000666 0000000 0000000 00000000064 15015565503 0014517 g ustar 00root root 0000000 0000000 52 comment=06b17b064889d91e3d0d0e1a23af47cffb5695e4 python-inline-snapshot-0.23.2/ 0000775 0000000 0000000 00000000000 15015565503 0016235 5 ustar 00root root 0000000 0000000 python-inline-snapshot-0.23.2/.github/ 0000775 0000000 0000000 00000000000 15015565503 0017575 5 ustar 00root root 0000000 0000000 python-inline-snapshot-0.23.2/.github/FUNDING.yml 0000664 0000000 0000000 00000000020 15015565503 0021402 0 ustar 00root root 0000000 0000000 github: 15r10nk python-inline-snapshot-0.23.2/.github/actions/ 0000775 0000000 0000000 00000000000 15015565503 0021235 5 ustar 00root root 0000000 0000000 python-inline-snapshot-0.23.2/.github/actions/setup/ 0000775 0000000 0000000 00000000000 15015565503 0022375 5 ustar 00root root 0000000 0000000 python-inline-snapshot-0.23.2/.github/actions/setup/action.yml 0000664 0000000 0000000 00000001042 15015565503 0024372 0 ustar 00root root 0000000 0000000 name: General Setup description: checkout & setup python inputs: python-version: # id of input description: the python version to use required: false default: '3.12' runs: using: composite steps: - name: Install uv uses: astral-sh/setup-uv@v5 with: python-version: ${{inputs.python-version}} - name: Set up Python uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 with: python-version: ${{inputs.python-version}} architecture: x64 allow-prereleases: true python-inline-snapshot-0.23.2/.github/pull_request_template.md 0000664 0000000 0000000 00000001442 15015565503 0024537 0 ustar 00root root 0000000 0000000 ## Description ## Related Issue(s) ## Checklist - [ ] I have tested my changes thoroughly (you can download the test coverage with `hatch run cov:github`). - [ ] I have added/updated relevant documentation. - [ ] I have added tests for new functionality (if applicable). - [ ] I have reviewed my own code for errors. - [ ] I have added a changelog entry with `hatch run changelog:entry` - [ ] I used semantic commits (`feat:` will cause a major and `fix:` a minor version bump) - [ ] You can squash you commits, otherwise they will be squashed during merge python-inline-snapshot-0.23.2/.github/workflows/ 0000775 0000000 0000000 00000000000 15015565503 0021632 5 ustar 00root root 0000000 0000000 python-inline-snapshot-0.23.2/.github/workflows/ci.yml 0000664 0000000 0000000 00000010207 15015565503 0022750 0 ustar 00root root 0000000 0000000 name: CI on: pull_request: push: branches: [main] jobs: mypy: runs-on: ubuntu-latest strategy: matrix: python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: ./.github/actions/setup with: python-version: ${{matrix.python-version}} - run: uvx hatch run +py=${{matrix.python-version}} types:check test: runs-on: ${{matrix.os}} strategy: matrix: python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', pypy3.9, pypy3.10] os: [ubuntu-latest, windows-latest, macos-13] extra_deps: ['"--with=pydantic<2"', '"--with=pydantic>2"'] env: TOP: ${{github.workspace}} COVERAGE_PROCESS_START: ${{github.workspace}}/pyproject.toml steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: ./.github/actions/setup with: python-version: ${{matrix.python-version}} - run: | uv run ${{matrix.extra_deps}} --extra black --extra dirty-equals -m ${{ matrix.os == 'ubuntu-latest' && 'coverage run -m' || '' }} pytest -n=auto -vv - run: | uv run -m coverage combine mv .coverage .coverage.${{ matrix.python-version }}-${{matrix.os}}-${{strategy.job-index}} if: matrix.os == 'ubuntu-latest' - name: Upload coverage data uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 if: matrix.os == 'ubuntu-latest' with: name: coverage-data-${{github.run_id}}-${{ matrix.python-version }}-${{matrix.os}}-${{strategy.job-index}} path: .coverage.* include-hidden-files: true if-no-files-found: ignore coverage: name: Combine & check coverage env: TOP: ${{github.workspace}} if: always() needs: test runs-on: ubuntu-latest steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: ./.github/actions/setup - uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9 with: pattern: coverage-data-${{github.run_id}}-* merge-multiple: true - name: Combine coverage & fail if it's <100% run: | uv pip install --upgrade coverage[toml] coverage combine coverage html --skip-covered --skip-empty # Report and write to summary. coverage report --format=markdown >> $GITHUB_STEP_SUMMARY # Report again and fail if under 100%. coverage report --fail-under=100 - name: Upload HTML report if check failed uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 with: name: html-report path: htmlcov if: ${{ failure() }} publish: name: Publish new release runs-on: ubuntu-latest needs: [test, coverage] environment: pypi permissions: # IMPORTANT: this permission is mandatory for Trusted Publishing id-token: write # this permission is mandatory to create github releases contents: write steps: - name: Checkout main uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: fetch-depth: 0 - uses: ./.github/actions/setup - name: Check if the commit has a vx.y.z tag id: check-version run: | if git tag --list --points-at ${{ github.sha }} | grep -q -E '^v[0-9]+\.[0-9]+\.[0-9]+$'; then echo "is new version" echo "should_continue=true" >> "$GITHUB_OUTPUT" else echo "is not a new version" echo "should_continue=false" >> "$GITHUB_OUTPUT" fi - run: uv pip install hatch scriv - name: build package run: hatch build - name: Publish package distributions to PyPI if: ${{ steps.check-version.outputs.should_continue == 'true' }} uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4 - name: create github release if: ${{ steps.check-version.outputs.should_continue == 'true' }} env: GITHUB_TOKEN: ${{ github.token }} run: scriv github-release python-inline-snapshot-0.23.2/.github/workflows/deploy_development_docs.yml 0000664 0000000 0000000 00000001122 15015565503 0027257 0 ustar 00root root 0000000 0000000 name: deploy development docs on: push: branches: [main] jobs: build: name: Deploy development docs runs-on: ubuntu-latest steps: - name: Checkout main uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - run: pip install hatch - 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 python-inline-snapshot-0.23.2/.github/workflows/docs.yml 0000664 0000000 0000000 00000001366 15015565503 0023313 0 ustar 00root root 0000000 0000000 name: Publish docs via GitHub Pages on: push: tags: - v[0-9]+.[0-9]+.[0-9]+ jobs: build: name: Deploy docs for new version runs-on: ubuntu-latest steps: - name: Checkout main uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - run: pip install hatch - 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 }} 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 -u --push ${INLINE_SNAPSHOT_VERSION} latest python-inline-snapshot-0.23.2/.github/workflows/test_docs.yml 0000664 0000000 0000000 00000000503 15015565503 0024342 0 ustar 00root root 0000000 0000000 name: test docs on: pull_request: jobs: build: name: Deploy development docs runs-on: ubuntu-latest steps: - name: Checkout main uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - run: pip install hatch - name: test docs run: | hatch run docs:build python-inline-snapshot-0.23.2/.gitignore 0000664 0000000 0000000 00000001613 15015565503 0020226 0 ustar 00root root 0000000 0000000 # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python env/ build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ *.egg-info/ .installed.cfg *.egg # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *,cover .hypothesis/ .pytest_cache # Translations *.mo *.pot # Django stuff: *.log local_settings.py # Flask instance folder instance/ # Sphinx documentation docs/_build/ # MkDocs documentation /site/ # PyBuilder target/ # IPython Notebook .ipynb_checkpoints # pyenv .python-version .mutmut-cache html python-inline-snapshot-0.23.2/.pre-commit-config.yaml 0000664 0000000 0000000 00000004102 15015565503 0022513 0 ustar 00root root 0000000 0000000 ci: autofix_pr: false autoupdate_commit_msg: 'style: pre-commit autoupdate' autofix_commit_msg: 'style: pre-commit fixed styling' autoupdate_schedule: monthly repos: - hooks: - id: check-ast - id: check-merge-conflict - id: trailing-whitespace - id: mixed-line-ending - id: fix-byte-order-marker - id: check-case-conflict - id: check-json - id: end-of-file-fixer repo: https://github.com/pre-commit/pre-commit-hooks rev: v5.0.0 - hooks: - args: - --in-place - --expand-star-imports - --remove-all-unused-imports - --ignore-init-module-imports id: autoflake repo: https://github.com/myint/autoflake rev: v2.3.1 - repo: local hooks: - id: replace-words name: Replace Words entry: python3 scripts/replace_words.py language: system files: \.(md|py)$ - repo: https://github.com/asottile/setup-cfg-fmt rev: v2.8.0 hooks: - id: setup-cfg-fmt - repo: https://github.com/pycqa/isort rev: 6.0.1 hooks: - id: isort name: isort (python) - hooks: - args: - --py38-plus id: pyupgrade repo: https://github.com/asottile/pyupgrade rev: v3.19.1 - hooks: - id: black repo: https://github.com/psf/black rev: 25.1.0 - hooks: - id: blacken-docs args: [-l80] repo: https://github.com/adamchainz/blacken-docs rev: 1.19.1 - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks rev: v2.14.0 hooks: - id: pretty-format-yaml args: [--autofix, --indent, '2'] - hooks: - id: commitizen stages: - commit-msg repo: https://github.com/commitizen-tools/commitizen rev: v4.6.1 # - repo: https://github.com/PyCQA/docformatter # rev: v1.7.5 # hooks: # - id: docformatter - repo: https://github.com/abravalheri/validate-pyproject rev: v0.24.1 hooks: - id: validate-pyproject # Optional extra validations from SchemaStore: additional_dependencies: ['validate-pyproject-schema-store[all]'] - repo: https://github.com/rhysd/actionlint rev: v1.7.7 hooks: - id: actionlint - repo: https://github.com/crate-ci/typos rev: v1.31.1 hooks: - id: typos python-inline-snapshot-0.23.2/CHANGELOG.md 0000664 0000000 0000000 00000042265 15015565503 0020057 0 ustar 00root root 0000000 0000000 # 0.23.2 — 2025-05-28 ## Fixed - The `readline` module doesn't have to be installed on non-windows systems. # 0.23.1 — 2025-05-26 ## Changed - changed how the `Snapshot[T]` type is implemented. ## Fixed - command line flags work again in CI (#242) # 0.23.0 — 2025-04-25 ## Changed - snapshot updates are now disabled by default. They be enabled with `show-updates=true` in your config. This is done because they can confuse new inline-snapshot users and does not fit the way how most users work with inline-snapshot. updates will become much more useful when (#177) is implemented. # 0.22.3 — 2025-04-14 ## Fixed - A pycharm environment is no longer incorrectly recognized as a CI environment. # 0.22.2 — 2025-04-14 ## Fixed - show correct diff when `pytest --inline-snapshot=report -vv` is used (#231) # 0.22.1 — 2025-04-11 ## Fixed - The environment variable `INLINE_SNAPSHOT_DEFAULT_FLAGS` now takes precedence over all default flags defined in *pyproject.toml*. - inline-snapshot can now be used in combination with `pytester.runpytest()` # 0.22.0 — 2025-04-03 ## Added - You can now use the config option `skip-snapshot-updates-for-now` to skip the reporting of updates. But be aware that this option might not be there forever. Please create an issue if you think that the creation of snapshots can be improved. # 0.21.3 — 2025-04-02 ## Fixed - Allowed inline-snapshot to work when pytest-xdist is disabled with `-n 0`. # 0.21.2 — 2025-03-31 ## Fixed - `repr(Is(x))` returns the same value as `repr(x)` to provide nice pytest outputs (#217) # 0.21.1 — 2025-03-29 ## Changed - trailing white spaces in multi-line strings are now terminated with an `\n\`. ``` python def test_something(): assert "a \nb\n" == snapshot( """\ a \n\ b """ ) ``` # 0.21.0 — 2025-03-28 ## Changed - inline-snapshot uses now `--inline-snapshot=disable` during CI runs by default. This improves performance because `snapshot()` is then equal to: ``` python def snapshot(x): return x ``` It also has benefits for the accuracy of your tests as it is less likely that inline snapshot will affect your tests in CI. - The default flags have changed for cpython >= 3.11: * `--inline-snapshot=create,review` is used in an interactive terminal and * `--inline-snapshot=report` otherwise. - The categories in the terminal output are now links to the documentation if it is supported by the terminal. ## Fixed - Hide update section if the diff is empty because the change is reverted by the format-command. # 0.20.10 — 2025-03-26 ## Fixed - Use of the correct snapshot category (update/fix) when deleting dataclass arguments. # 0.20.9 — 2025-03-23 ## Fixed - `--inline-snapshot=create` preserves test failures now. # 0.20.8 — 2025-03-20 ## Fixed - inline-snapshot now also works if you use `--no-summary` (which pycharm does if you run your tests from the IDE). # 0.20.7 — 2025-03-14 ## Changed - Tests with failed snapshot comparisons now always result in a pytest `Error`, even if snapshots have been fixed or created. # 0.20.6 — 2025-03-13 ## Fixed - Do not skip snapshots in conditional marked xfail tests. ``` python @pytest.mark.xfail(False, reason="...") def test_a(): assert 5 == snapshot(3) # <- this will be fixed @pytest.mark.xfail(True, reason="...") def test_b(): assert 5 == snapshot(3) # <- this not ``` # 0.20.5 — 2025-03-04 ## Fixed - correct normalization of "python3.9" to "python" in tests # 0.20.4 — 2025-03-03 ## Fixed - Prevent a crash if a value cannot be copied and a UsageError is raised. # 0.20.3 — 2025-02-28 ## Fixed - Use the black API directly to format python code. This solves issues with the upcoming click 8.2.0 (#202) and problems in multithreading (https://github.com/15r10nk/inline-snapshot/pull/193#issuecomment-2660393512). # 0.20.2 — 2025-02-13 ## Fixed - snapshots inside tests which are marked as xfail are now ignored (#184) - Fixed a crash caused by the following code: ``` python snapshot(tuple()) # or snapshot(dict()) ``` # 0.20.1 — 2025-02-04 ## Fixed - Fixed a windows bug with the readline module (#189) # 0.20.0 — 2025-02-01 ## Changed - pytest assert rewriting works now together with inline-snapshot if you use `cpython>=3.11` - `...` is now a special value to *create* snapshot values. The value change in `assert [5,4] == snapshot([5,...])` is now a *create* (previously it was a *fix*) ## Fixed - fixed some issues with dataclass arguments - fixed an issue where --inline-snapshot=review discarded the user input and never formatted the code if you used cpython 3.13. # 0.19.3 — 2025-01-15 ## Fixed - raise no assertion for positional arguments inside constructor methods. # 0.19.2 — 2025-01-15 ## Fixed - fixed a crash when you changed the snapshot to use a custom constructor method for dataclass/pydantic models. example: ``` python from inline_snapshot import snapshot from pydantic import BaseModel class A(BaseModel): a: int @classmethod def from_str(cls, s): return cls(a=int(s)) def test_something(): assert A(a=2) == snapshot(A.from_str("1")) ``` # 0.19.1 — 2025-01-12 ## Added - added the optional `inline-snapshot[dirty-equals]` dependency to depend on the dirty-equals version which works in combination with inline-snapshot. ## Fixed - snapshots with pydantic models can now be compared multiple times ``` python class A(BaseModel): a: int def test_something(): for _ in [1, 2]: assert A(a=1) == snapshot(A(a=1)) ``` # 0.19.0 — 2025-01-10 ## Added - You can now specify which tool you want to use to format your code by setting a `format-command` in your [configuration](https://15r10nk.github.io/inline-snapshot/latest/configuration/#format-command). ## Changed - **BREAKING-CHANGE** you have to install `inline-snapshot[black]` now if you want to format your code like in the previous versions. This option is not required if you use a `format-command`. ## Fixed - Load default config values even if `[tool.inline-snapshot]` is missing. This makes the documented default shortcuts `--review` and `--fix` work. # 0.18.2 — 2025-01-02 ## Changed - added `[dependency-groups]` to *pyproject.toml* and use uv and pytest to run tests in CI. ## Fixed - use '.model_fields' on pydantic model class and not instance. This fixes a deprecation warning in the upcoming pydantic v2.11 (#169) # 0.18.1 — 2024-12-22 ## Fixed - uv is now only used during test time if you run the inline-snapshot tests with `pytest --use-uv` This solves a problem if you want to package inline-snapshot in distributions (#165) # 0.18.0 — 2024-12-21 ## Added - Support for a new `storage-dir` configuration option, to tell inline-snapshot where to store data files such as external snapshots. ## Fixed - pydantic v1 is supported again. pydantic v1 & v2 create now the same snapshots. You can use `.dict()` to get the same snapshots like in inline-snapshot-0.15.0 for pydantic v1. ``` python class M(BaseModel): name: str def test_pydantic(): m = M(name="Tom") assert m == snapshot(M(name="Tom")) assert m.dict() == snapshot({"name": "Tom"}) ``` - Find `pyproject.toml` file in parent directories, not just next to the Pytest configuration file. # 0.17.1 — 2024-12-17 ## Fixed - Code generation for sets is now deterministic. ``` python def test(): assert {1j, 2j, 1, 2, 3} == snapshot({1, 1j, 2, 2j, 3}) ``` # 0.17.0 — 2024-12-14 ## Added - [attrs](https://www.attrs.org/en/stable/index.html) can now contain unmanaged values ``` python import datetime as dt import uuid import attrs from dirty_equals import IsDatetime from inline_snapshot import Is, snapshot @attrs.define class Attrs: ts: dt.datetime id: uuid.UUID def test(): id = uuid.uuid4() assert Attrs(dt.datetime.now(), id) == snapshot( Attrs(ts=IsDatetime(), id=Is(id)) ) ``` # 0.16.0 — 2024-12-12 ## Added - [`inline_snapshot.extra.warns`](https://15r10nk.github.io/inline-snapshot/latest/extra/#inline_snapshot.extra.warns) to captures warnings and compares them against expected warnings. ``` python def test_warns(): with warns(snapshot([(8, "UserWarning: some problem")]), include_line=True): warn("some problem") ``` # 0.15.1 — 2024-12-10 ## Fixed - solved a bug caused by a variable inside a snapshot (#148) # 0.15.0 — 2024-12-10 ## Added - snapshots [inside snapshots](https://15r10nk.github.io/inline-snapshot/latest/eq_snapshot/#inner-snapshots) are now supported. ``` python assert get_schema() == snapshot( [ { "name": "var_1", "type": snapshot("int") if version < 2 else snapshot("string"), } ] ) ``` - [runtime values](https://15r10nk.github.io/inline-snapshot/latest/eq_snapshot/#is) can now be part of snapshots. ``` python from inline_snapshot import snapshot, Is current_version = "1.5" assert request() == snapshot( {"data": "page data", "version": Is(current_version)} ) ``` - [f-strings](https://15r10nk.github.io/inline-snapshot/latest/eq_snapshot/#f-strings) can now also be used within snapshots, but are currently not *fixed* by inline-snapshot. ## Changed - *dirty-equals* expressions are now treated like *runtime values* or *snapshots* within snapshots and are not modified by inline-snapshot. ## Fixed - inline-snapshot checks now if the given command line flags (`--inline-snapshot=...`) are valid - `Example(...).run_pytest(raise=snapshot(...))` uses now the flags from the current run and not the flags from the Example. # 0.14.2 — 2024-12-07 ## Fixed - do not crash when handling raw f-strings (`rf""`,`RF""`,...) (#143) # 0.14.1 — 2024-12-04 ## Fixed - Don't crash for snapshots like `snapshot(f"")` (#139) It first appeared with pytest-8.3.4, but already existed before for cpython-3.11. f-strings in snapshots are currently not official supported, but they should not lead to crashes. - skip formatting if black returns an error (#138) # 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/latest/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. # 0.13.4 — 2024-11-07 ## Changed - use tomli instead of toml (#130) # 0.13.3 — 2024-09-24 ## Fixed - removed non-optional dirty-equals dependency (#118) # 0.13.2 — 2024-09-24 ## Changed - star-expressions in list or dicts where never valid and cause a warning now. ``` other=[2] assert [5,2]==snapshot([5,*other]) ``` ## Fixed - A snapshot which contains an dirty-equals expression can now be compared multiple times. ``` python def test_something(): greeting = "hello" for name in ["alex", "bob"]: assert (name, greeting) == snapshot((IsString(), "hello")) ``` ## v0.13.1 (2024-09-18) ### Fix - Use tomllib instead of PyPI toml on Python 3.11 and later ## v0.13.0 (2024-09-10) ### Feat - added extra.prints - 3.13 support - strings with one line-break at the end become no multiline strings ## v0.12.1 (2024-08-05) ### Fix - add license to project metadata and some other fixes in pyproject.toml (#104) ## v0.12.0 (2024-07-22) ### Feat - implement extra.raises - added inline_snapshot.testing.Example which can be used to test 3rd-party extensions ## v0.11.0 (2024-07-07) ### Feat - check if the result of copy.deepcopy() is equal to the copied value - support for `enum.Enum`, `enum.Flag`, `type` and omitting of default values (#73) ## v0.10.2 (2024-05-28) ### Fix - changed how --inline-snapshot=disable works in combination with xdist (#90) - fix typo, rename 'theme' with 'them' ## v0.10.1 (2024-05-26) ### Fix - trigger no update for trailing comma changes ## v0.10.0 (2024-05-21) ### BREAKING CHANGE - removed support for python 3.7 - removed `--inline-snapshot-disable` option and replaced it with `--inline-snapshot=disable` ### Feat - new flags: *disable*, *short-report*, *report* and *review* - added config option and environment variable to specify default flags - show diff of changed snapshots in pytest report - interactive *review* mode ## v0.9.0 (2024-05-07) ### Feat - check if inline-snapshot is used in combination with xdist and notify the user that this is not possible ### Fix - change the quoting of strings does not trigger an update ## v0.8.2 (2024-04-24) ### Fix - removed restriction that the snapshot functions has to be called snapshot (#72) - report error in tear down for sub-snapshots with missing values (#70) - element access in sub-snapshots does not create new values ## v0.8.1 (2024-04-22) ### Fix - make typing less strict ## v0.8.0 (2024-04-09) ### Feat - prevent dirty-equal values from triggering of updates - fix lists by calculating the alignment of the changed values - insert dict items - delete dict items - preserve not changed dict-values and list-elements ### Fix - update with UndecidedValue - handle dicts with multiple insertions and deletions - handle lists with multiple insertions and deletions - fixed typing and coverage ### Refactor - removed old _needs_* logic - removed get_result - use _get_changes api for DictValue - use _get_changes api for CollectionValue - use _get_changes api for MinMaxValue - use _get_changes - moved some functions ## v0.7.0 (2024-02-27) ### Feat - removed old --update-snapshots option ## v0.6.1 (2024-01-28) ### Fix - use utf-8 encoding to read and write source files ## v0.6.0 (2023-12-10) ### Feat - store snapshot values in external files ## v0.5.2 (2023-11-13) ### Fix - remove upper bound from dependency in pyproject.toml ## v0.5.1 (2023-10-20) ### Fix - show better error messages ## v0.5.0 (2023-10-15) ### Feat - support 3.12 ### Fix - do not change empty snapshot if it is not used ## v0.4.0 (2023-09-29) ### Feat - escaped linebreak at the start/end of multiline strings ### Fix - added py.typed ## v0.3.2 (2023-07-31) ### Fix - handle update flag in sub-snapshots correctly - fixed some edge cases where sub-snapshots had problems with some flags - string literal concatenation should trigger no update ## v0.3.1 (2023-07-14) ### Fix - added `__all__` to inline_snapshot - flags fix/trim/create/update are changing the matching snapshots ## v0.3.0 (2023-07-12) ### BREAKING CHANGE - values have to be copyable with `copy.deepcopy` ### Fix - snapshot the current value of mutable objects ``` python l = [1] assert l == snapshot([1]) # old behaviour: snapshot([1, 2]) l.append(2) assert l == snapshot([1, 2]) ``` ## v0.2.1 (2023-07-09) ### Fix - black configuration files are respected ## v0.2.0 (2023-06-20) ### Feat - `value <= snapshot()` to ensure that something gets smaller/larger over time (number of iterations of an algorithm you want to optimize for example), - `value in snapshot()` to check if your value is in a known set of values, - `snapshot()[key]` to generate new sub-snapshots on demand. - convert strings with newlines to triple quoted strings ``` python assert "a\nb\n" == snapshot( """a b """ ) ``` - preserve black formatting ## v0.1.2 (2022-12-11) ### Fix - updated executing ## v0.1.1 (2022-12-08) ### Fix - fixed typo in pytest plugin name ## v0.1.0 (2022-07-25) ### Feat - first inline-snapshot version python-inline-snapshot-0.23.2/CONTRIBUTING.md 0000664 0000000 0000000 00000002726 15015565503 0020475 0 ustar 00root root 0000000 0000000 # Contributing Contributions are welcome. Please create an issue before writing a pull request so we can discuss what needs to be changed. # Testing The code can be tested with [hatch](https://hatch.pypa.io/latest/tutorials/testing/overview/) * `hatch test` can be used to test all supported python versions and to check for coverage. * `hatch test -py 3.10 -- --sw` runs pytest for python 3.10 with the `--sw` argument. The preferred way to test inline-snapshot is by using [`inline-snapshot.texting.Example`](https://15r10nk.github.io/inline-snapshot/latest/testing/). You will see some other fixtures which are used inside the tests, but these are old ways to write the tests and I try to use the new `Example` class to write new tests. # Coverage This project has a hard coverage requirement of 100% (which is checked in CI). You can also check the coverage locally with `hatch test -acp`. The goal here is to find different edge cases which might have bugs. However, it is possible to exclude some code from the coverage. Code can be marked with `pragma: no cover`, if it can not be tested for some reason. This makes it easy to spot uncovered code in the source. Impossible conditions can be handled with `assert False`. ``` python if some_condition: ... if some_other_condition: ... else: assert False, "unreachable because ..." ``` This serves also as an additional check during runtime. # Commits Please use [pre-commit](https://pre-commit.com/) for your commits. python-inline-snapshot-0.23.2/LICENSE 0000664 0000000 0000000 00000002072 15015565503 0017243 0 ustar 00root root 0000000 0000000 The MIT License (MIT) Copyright (c) 2022 Frank Hoffmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. python-inline-snapshot-0.23.2/MANIFEST.in 0000664 0000000 0000000 00000000141 15015565503 0017767 0 ustar 00root root 0000000 0000000 include LICENSE include README.rst recursive-exclude * __pycache__ recursive-exclude * *.py[co] python-inline-snapshot-0.23.2/README.md 0000664 0000000 0000000 00000016616 15015565503 0017526 0 ustar 00root root 0000000 0000000
 [](https://15r10nk.github.io/inline-snapshot/latest/) [](https://pypi.org/project/inline-snapshot/)  [](https://pypacktrends.com/?packages=inline-snapshot&time_range=2years) [](https://15r10nk.github.io/inline-snapshot/latest/contributing/#coverage) [](https://github.com/sponsors/15r10nk) ## Installation You can install "inline-snapshot" via [pip](https://pypi.org/project/pip/): ``` bash pip install inline-snapshot ``` > [!IMPORTANT] > Hello, I would like to inform you about some changes. I have started to offer [insider](https://15r10nk.github.io/inline-snapshot/latest/insiders/) features for inline-snapshot. I will only release features as insider features if they will not cause problems for you when used in an open source project. > I hope sponsoring will allow me to spend more time working on open source projects. > Thank you for using inline-snapshot, the future will be 🚀. ## Key Features - **support for normal assertions:** inline-snapshot can now also fix normal assertions which do not use `snapshot()` like: ``` python assert 1 + 1 == 3 ``` You can learn [here](fix_assert.md) more about this feature. - **Intuitive Semantics:** `snapshot(x)` mirrors `x` for easy understanding. - **Versatile Comparison Support:** Equipped with [`x == snapshot(...)`](https://15r10nk.github.io/inline-snapshot/latest/eq_snapshot/), [`x <= snapshot(...)`](https://15r10nk.github.io/inline-snapshot/latest/cmp_snapshot/), [`x in snapshot(...)`](https://15r10nk.github.io/inline-snapshot/latest/in_snapshot/), and [`snapshot(...)[key]`](https://15r10nk.github.io/inline-snapshot/latest/getitem_snapshot/). - **Enhanced Control Flags:** Utilize various [flags](https://15r10nk.github.io/inline-snapshot/latest/pytest/) for precise control of which snapshots you want to change. - **Preserved Black Formatting:** Retains formatting consistency with Black formatting. - **External File Storage:** Store snapshots externally using `outsource(data)`. - **Seamless Pytest Integration:** Integrated seamlessly with pytest for effortless testing. - **Customizable:** code generation can be customized with [@customize_repr](https://15r10nk.github.io/inline-snapshot/latest/customize_repr) - **Nested Snapshot Support:** snapshots can contain [other snapshots](https://15r10nk.github.io/inline-snapshot/latest/eq_snapshot/#inner-snapshots) - **Fuzzy Matching:** Incorporate [dirty-equals](https://15r10nk.github.io/inline-snapshot/latest/eq_snapshot/#dirty-equals) for flexible comparisons within snapshots. - **Dynamic Snapshot Content:** snashots can contain [non-constant values](https://15r10nk.github.io/inline-snapshot/latest/eq_snapshot/#is) - **Comprehensive Documentation:** Access detailed [documentation](https://15r10nk.github.io/inline-snapshot/latest) for complete guidance. ## Usage You can use `snapshot()` instead of the value which you want to compare with. ``` python from inline_snapshot import snapshot def test_something(): assert 1548 * 18489 == snapshot() ``` You can now run the tests and record the correct values. ``` $ pytest --inline-snapshot=review ``` ``` python hl_lines="5" from inline_snapshot import snapshot def test_something(): assert 1548 * 18489 == snapshot(28620972) ``` The following examples show how you can use inline-snapshot in your tests. Take a look at the [documentation](https://15r10nk.github.io/inline-snapshot/latest) if you want to know more. ``` python from inline_snapshot import snapshot, outsource, external def test_something(): for number in range(5): # testing for numeric limits assert number <= snapshot(4) assert number >= snapshot(0) for c in "hello world": # test if something is part of a set assert c in snapshot(["h", "e", "l", "o", " ", "w", "r", "d"]) s = snapshot( { 0: {"square": 0, "pow_of_two": False}, 1: {"square": 1, "pow_of_two": True}, 2: {"square": 4, "pow_of_two": True}, 3: {"square": 9, "pow_of_two": False}, 4: {"square": 16, "pow_of_two": True}, } ) for number in range(5): # create sub-snapshots at runtime assert s[number]["square"] == number**2 assert s[number]["pow_of_two"] == ( (number & (number - 1) == 0) and number != 0 ) assert outsource("large string\n" * 1000) == snapshot( external("8bf10bdf2c30*.txt") ) assert "generates\nmultiline\nstrings" == snapshot( """\ generates multiline strings\ """ ) ``` `snapshot()` can also be used as parameter for functions: ``` python from inline_snapshot import snapshot import subprocess as sp import sys def run_python(cmd, stdout=None, stderr=None): result = sp.run([sys.executable, "-c", cmd], capture_output=True) if stdout is not None: assert result.stdout.decode() == stdout if stderr is not None: assert result.stderr.decode() == stderr def test_cmd(): run_python( "print('hello world')", stdout=snapshot( """\ hello world """ ), stderr=snapshot(""), ) run_python( "1/0", stdout=snapshot(""), stderr=snapshot( """\ Traceback (most recent call last): File "