Disables all the snapshot logic. snapshot(x)
will just return x
.\n This can be used if you think exclude that snapshot logic causes a problem in your tests, or if you want to speedup your CI.
\n \n
deprecation
\n
This option was previously called --inline-snapshot-disable
\n", "details": [{"source1": "html2text {}", "source2": "html2text {}", "unified_diff": "@@ -66,17 +66,17 @@\n def test_something():\n assert 1 == snapshot()\n assert 2 <= snapshot(5)\n [1;34m> pytest test_something.py --inline-snapshot=create,report\n [0m\u001b[1m============================= test session starts\n ==============================\u001b[0m\n platform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0\n-rootdir: /tmp/tmp.CETKrEZFtC\n-plugins: pytest_freezer-0.4.8, hypothesis-6.122.1, typeguard-4.4.1, time-\n-machine-2.14.1, subtests-0.13.1, inline-snapshot-0.14.0\n+rootdir: /tmp/tmp.Wt1lijWNCQ\n+plugins: hypothesis-6.122.1, typeguard-4.4.1, inline-snapshot-0.14.0, time-\n+machine-2.14.1, subtests-0.13.1, pytest_freezer-0.4.8\n collected 1 item\n \n test_something.py \u001b[32m.\u001b[0m\u001b[32m\n [100%]\u001b[0m\n =============================== inline snapshot\n ================================\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 Create snapshots\n@@ -124,25 +124,25 @@\n +------------------------------------------------------------------------------\n +\n These changes are not applied.\n Use --inline-snapshot=trim to apply them, or use the interactive mode with\n --inline-snapshot=review\n \n \n-[32m============================== \u001b[32m\u001b[1m1 passed\u001b[0m\u001b[32m in 0.16s\u001b[0m\u001b[32m\n+[32m============================== \u001b[32m\u001b[1m1 passed\u001b[0m\u001b[32m in 0.11s\u001b[0m\u001b[32m\n ===============================\u001b[0m\n *\b**\b**\b**\b**\b* -\b--\b-i\bin\bnl\bli\bin\bne\be-\b-s\bsn\bna\bap\bps\bsh\bho\bot\bt=\b=s\bsh\bho\bor\brt\bt-\b-r\bre\bep\bpo\bor\brt\bt_\b?\b\u00b6 *\b**\b**\b**\b**\b*\n give a short report over which changes can be made to the snapshots\n [1;34m> pytest test_something.py --inline-snapshot=short-report\n [0m\u001b[1m============================= test session starts\n ==============================\u001b[0m\n platform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0\n-rootdir: /tmp/tmp.OH39pszdwB\n-plugins: pytest_freezer-0.4.8, hypothesis-6.122.1, typeguard-4.4.1, time-\n-machine-2.14.1, subtests-0.13.1, inline-snapshot-0.14.0\n+rootdir: /tmp/tmp.78DgZaOzgR\n+plugins: hypothesis-6.122.1, typeguard-4.4.1, inline-snapshot-0.14.0, time-\n+machine-2.14.1, subtests-0.13.1, pytest_freezer-0.4.8\n collected 1 item\n \n test_something.py \u001b[32m.\u001b[0m\u001b[31mE\u001b[0m\u001b[31m\n [100%]\u001b[0m\n \n ==================================== ERRORS\n ====================================\n@@ -156,28 +156,28 @@\n \n You can also use --inline-snapshot=review to approve the changes interactively\n [36m\u001b[1m=========================== short test summary info\n ============================\u001b[0m\n [31mERROR\u001b[0m test_something.py::\u001b[1mtest_something\u001b[0m - Failed: your snapshot\n is missing one value.\n [31m========================== \u001b[32m1 passed\u001b[0m, \u001b[31m\u001b[1m1 error\u001b[0m\u001b[31m in\n-0.16s\u001b[0m\u001b[31m ==========================\u001b[0m\n+0.13s\u001b[0m\u001b[31m ==========================\u001b[0m\n Info\n short-report exists mainly to show that snapshots have changed with enabled\n pytest assert-rewriting. This option will be replaced with r\bre\bep\bpo\bor\brt\bt when this\n restriction is lifted.\n *\b**\b**\b**\b**\b* -\b--\b-i\bin\bnl\bli\bin\bne\be-\b-s\bsn\bna\bap\bps\bsh\bho\bot\bt=\b=r\bre\bep\bpo\bor\brt\bt_\b?\b\u00b6 *\b**\b**\b**\b**\b*\n Shows a diff report over which changes can be made to the snapshots\n [1;34m> pytest test_something.py --inline-snapshot=report\n [0m\u001b[1m============================= test session starts\n ==============================\u001b[0m\n platform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0\n-rootdir: /tmp/tmp.uRkCyvpEg8\n-plugins: pytest_freezer-0.4.8, hypothesis-6.122.1, typeguard-4.4.1, time-\n-machine-2.14.1, subtests-0.13.1, inline-snapshot-0.14.0\n+rootdir: /tmp/tmp.BAEOfeFGMp\n+plugins: hypothesis-6.122.1, typeguard-4.4.1, inline-snapshot-0.14.0, time-\n+machine-2.14.1, subtests-0.13.1, pytest_freezer-0.4.8\n collected 1 item\n \n test_something.py \u001b[32m.\u001b[0m\u001b[31mE\u001b[0m\u001b[31m\n [100%]\u001b[0m\n \n ==================================== ERRORS\n ====================================\n@@ -237,24 +237,24 @@\n --inline-snapshot=review\n \n [36m\u001b[1m=========================== short test summary info\n ============================\u001b[0m\n [31mERROR\u001b[0m test_something.py::\u001b[1mtest_something\u001b[0m - Failed: your snapshot\n is missing one value.\n [31m========================== \u001b[32m1 passed\u001b[0m, \u001b[31m\u001b[1m1 error\u001b[0m\u001b[31m in\n-0.18s\u001b[0m\u001b[31m ==========================\u001b[0m\n+0.21s\u001b[0m\u001b[31m ==========================\u001b[0m\n *\b**\b**\b**\b**\b* -\b--\b-i\bin\bnl\bli\bin\bne\be-\b-s\bsn\bna\bap\bps\bsh\bho\bot\bt=\b=r\bre\bev\bvi\bie\bew\bw_\b?\b\u00b6 *\b**\b**\b**\b**\b*\n Shows a diff report for each category and ask if you want to apply the changes\n [1;34m> pytest test_something.py --inline-snapshot=review\n [0m\u001b[1m============================= test session starts\n ==============================\u001b[0m\n platform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0\n-rootdir: /tmp/tmp.hpELK540k1\n-plugins: pytest_freezer-0.4.8, hypothesis-6.122.1, typeguard-4.4.1, time-\n-machine-2.14.1, subtests-0.13.1, inline-snapshot-0.14.0\n+rootdir: /tmp/tmp.y5TdogDd7R\n+plugins: hypothesis-6.122.1, typeguard-4.4.1, inline-snapshot-0.14.0, time-\n+machine-2.14.1, subtests-0.13.1, pytest_freezer-0.4.8\n collected 1 item\n \n test_something.py \u001b[32m.\u001b[0m\u001b[32m\n [100%]\u001b[0m\n =============================== inline snapshot\n ================================\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 Create snapshots\n@@ -298,15 +298,15 @@\n |\n | + assert 2 <= snapshot(2)\n |\n +------------------------------------------------------------------------------\n +\n do you want to trim these snapshots? [y/n] (n):\n \n-[32m============================== \u001b[32m\u001b[1m1 passed\u001b[0m\u001b[32m in 0.23s\u001b[0m\u001b[32m\n+[32m============================== \u001b[32m\u001b[1m1 passed\u001b[0m\u001b[32m in 0.19s\u001b[0m\u001b[32m\n ===============================\u001b[0m\n *\b**\b**\b**\b**\b* -\b--\b-i\bin\bnl\bli\bin\bne\be-\b-s\bsn\bna\bap\bps\bsh\bho\bot\bt=\b=d\bdi\bis\bsa\bab\bbl\ble\be_\b?\b\u00b6 *\b**\b**\b**\b**\b*\n Disables all the snapshot logic. snapshot(x) will just return x. This can be\n used if you think exclude that snapshot logic causes a problem in your tests,\n or if you want to speedup your CI.\n deprecation\n This option was previously called --inline-snapshot-disable\n"}]}, {"source1": "./usr/share/doc/python-inline-snapshot-doc/html/search/search_index.json", "source2": "./usr/share/doc/python-inline-snapshot-doc/html/search/search_index.json", "unified_diff": null, "details": [{"source1": "Pretty-printed", "source2": "Pretty-printed", "comments": ["Similarity: 0.9965277777777778%", "Differences: {\"'docs'\": \"{106: {'text': '
Uses contextlib.redirect_stderr/stdout
to capture the \"", " 'output and compare it with the snapshots. dirty_equals.IsStr
can be used '", " 'to ignore the output if needed.
Parameters:
Name Type Description Default '", " '
stdout
Snapshot[str]
snapshot which is compared to the '", " \"recorded output
\\\\'\\\\'
stderr
Snapshot[str]
\"", " \"
The following functions are build on top of inline-snapshot and could also be implemented in an extra library.
They are part of inline-snapshot because they are general useful and do not depend on other libraries.
\",\n \"title\": \"
inline_snapshot.extra
\"\n },\n {\n \"location\": \"extra.html#inline_snapshot.extra.prints\",\n- \"text\": \"
Uses contextlib.redirect_stderr/stdout
to capture the output and compare it with the snapshots. dirty_equals.IsStr
can be used to ignore the output if needed.
Parameters:
Name Type Description Default
stdout
Snapshot[str]
snapshot which is compared to the recorded output
''
stderr
Snapshot[str]
snapshot which is compared to the recorded error output
''
original--inline-snapshot=createignore stdout
from inline_snapshot import snapshot\\nfrom inline_snapshot.extra import prints\\nimport sys\\n\\n\\ndef test_prints():\\n with prints(stdout=snapshot(), stderr=snapshot()):\\n print(\\\"hello world\\\")\\n print(\\\"some error\\\", file=sys.stderr)\\n
from inline_snapshot import snapshot\\nfrom inline_snapshot.extra import prints\\nimport sys\\n\\n\\ndef test_prints():\\n with prints(\\n stdout=snapshot(\\\"hello world\\\\n\\\"), stderr=snapshot(\\\"some error\\\\n\\\")\\n ):\\n print(\\\"hello world\\\")\\n print(\\\"some error\\\", file=sys.stderr)\\n
from inline_snapshot import snapshot\\nfrom inline_snapshot.extra import prints\\nfrom dirty_equals import IsStr\\nimport sys\\n\\n\\ndef test_prints():\\n with prints(\\n stdout=IsStr(),\\n stderr=snapshot(\\\"some error\\\\n\\\"),\\n ):\\n print(\\\"hello world\\\")\\n print(\\\"some error\\\", file=sys.stderr)\\n
Source code in
.pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/extra.py
@contextlib.contextmanager\\ndef prints(*, stdout: Snapshot[str] = \\\"\\\", stderr: Snapshot[str] = \\\"\\\"):\\n \\\"\\\"\\\"Uses `contextlib.redirect_stderr/stdout` to capture the output and\\n compare it with the snapshots. `dirty_equals.IsStr` can be used to ignore\\n the output if needed.\\n\\n Parameters:\\n stdout: snapshot which is compared to the recorded output\\n stderr: snapshot which is compared to the recorded error output\\n\\n === \\\"original\\\"\\n\\n <!-- inline-snapshot: first_block outcome-passed=1 outcome-errors=1 -->\\n ``` python\\n from inline_snapshot import snapshot\\n from inline_snapshot.extra import prints\\n import sys\\n\\n\\n def test_prints():\\n with prints(stdout=snapshot(), stderr=snapshot()):\\n print(\\\"hello world\\\")\\n print(\\\"some error\\\", file=sys.stderr)\\n ```\\n\\n === \\\"--inline-snapshot=create\\\"\\n\\n <!-- inline-snapshot: create outcome-passed=1 -->\\n ``` python hl_lines=\\\"7 8 9\\\"\\n from inline_snapshot import snapshot\\n from inline_snapshot.extra import prints\\n import sys\\n\\n\\n def test_prints():\\n with prints(\\n stdout=snapshot(\\\"hello world\\\\\\\\n\\\"), stderr=snapshot(\\\"some error\\\\\\\\n\\\")\\n ):\\n print(\\\"hello world\\\")\\n print(\\\"some error\\\", file=sys.stderr)\\n ```\\n\\n === \\\"ignore stdout\\\"\\n\\n <!-- inline-snapshot: outcome-passed=1 -->\\n ``` python hl_lines=\\\"3 9 10\\\"\\n from inline_snapshot import snapshot\\n from inline_snapshot.extra import prints\\n from dirty_equals import IsStr\\n import sys\\n\\n\\n def test_prints():\\n with prints(\\n stdout=IsStr(),\\n stderr=snapshot(\\\"some error\\\\\\\\n\\\"),\\n ):\\n print(\\\"hello world\\\")\\n print(\\\"some error\\\", file=sys.stderr)\\n ```\\n \\\"\\\"\\\"\\n\\n with redirect_stdout(io.StringIO()) as stdout_io:\\n with redirect_stderr(io.StringIO()) as stderr_io:\\n yield\\n\\n assert stderr_io.getvalue() == stderr\\n assert stdout_io.getvalue() == stdout\\n
\",\n+ \"text\": \"
Uses contextlib.redirect_stderr/stdout
to capture the output and compare it with the snapshots. dirty_equals.IsStr
can be used to ignore the output if needed.
Parameters:
Name Type Description Default
stdout
Snapshot[str]
snapshot which is compared to the recorded output
''
stderr
Snapshot[str]
snapshot which is compared to the recorded error output
''
original--inline-snapshot=createignore stdout
from inline_snapshot import snapshot\\nfrom inline_snapshot.extra import prints\\nimport sys\\n\\n\\ndef test_prints():\\n with prints(stdout=snapshot(), stderr=snapshot()):\\n print(\\\"hello world\\\")\\n print(\\\"some error\\\", file=sys.stderr)\\n
from inline_snapshot import snapshot\\nfrom inline_snapshot.extra import prints\\nimport sys\\n\\n\\ndef test_prints():\\n with prints(\\n stdout=snapshot(\\\"hello world\\\\n\\\"), stderr=snapshot(\\\"some error\\\\n\\\")\\n ):\\n print(\\\"hello world\\\")\\n print(\\\"some error\\\", file=sys.stderr)\\n
from inline_snapshot import snapshot\\nfrom inline_snapshot.extra import prints\\nfrom dirty_equals import IsStr\\nimport sys\\n\\n\\ndef test_prints():\\n with prints(\\n stdout=IsStr(),\\n stderr=snapshot(\\\"some error\\\\n\\\"),\\n ):\\n print(\\\"hello world\\\")\\n print(\\\"some error\\\", file=sys.stderr)\\n
Source code in
.pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/extra.py
@contextlib.contextmanager\\ndef prints(*, stdout: Snapshot[str] = \\\"\\\", stderr: Snapshot[str] = \\\"\\\"):\\n \\\"\\\"\\\"Uses `contextlib.redirect_stderr/stdout` to capture the output and\\n compare it with the snapshots. `dirty_equals.IsStr` can be used to ignore\\n the output if needed.\\n\\n Parameters:\\n stdout: snapshot which is compared to the recorded output\\n stderr: snapshot which is compared to the recorded error output\\n\\n === \\\"original\\\"\\n\\n <!-- inline-snapshot: first_block outcome-passed=1 outcome-errors=1 -->\\n ``` python\\n from inline_snapshot import snapshot\\n from inline_snapshot.extra import prints\\n import sys\\n\\n\\n def test_prints():\\n with prints(stdout=snapshot(), stderr=snapshot()):\\n print(\\\"hello world\\\")\\n print(\\\"some error\\\", file=sys.stderr)\\n ```\\n\\n === \\\"--inline-snapshot=create\\\"\\n\\n <!-- inline-snapshot: create outcome-passed=1 -->\\n ``` python hl_lines=\\\"7 8 9\\\"\\n from inline_snapshot import snapshot\\n from inline_snapshot.extra import prints\\n import sys\\n\\n\\n def test_prints():\\n with prints(\\n stdout=snapshot(\\\"hello world\\\\\\\\n\\\"), stderr=snapshot(\\\"some error\\\\\\\\n\\\")\\n ):\\n print(\\\"hello world\\\")\\n print(\\\"some error\\\", file=sys.stderr)\\n ```\\n\\n === \\\"ignore stdout\\\"\\n\\n <!-- inline-snapshot: outcome-passed=1 -->\\n ``` python hl_lines=\\\"3 9 10\\\"\\n from inline_snapshot import snapshot\\n from inline_snapshot.extra import prints\\n from dirty_equals import IsStr\\n import sys\\n\\n\\n def test_prints():\\n with prints(\\n stdout=IsStr(),\\n stderr=snapshot(\\\"some error\\\\\\\\n\\\"),\\n ):\\n print(\\\"hello world\\\")\\n print(\\\"some error\\\", file=sys.stderr)\\n ```\\n \\\"\\\"\\\"\\n\\n with redirect_stdout(io.StringIO()) as stdout_io:\\n with redirect_stderr(io.StringIO()) as stderr_io:\\n yield\\n\\n assert stderr_io.getvalue() == stderr\\n assert stdout_io.getvalue() == stdout\\n
\",\n \"title\": \"
prints(*, stdout='', stderr='')
\"\n },\n {\n \"location\": \"extra.html#inline_snapshot.extra.raises\",\n- \"text\": \"
Check that an exception is raised.
Parameters:
Name Type Description Default
exception
Snapshot[str]
snapshot which is compared with f\\\"{type}: {message}\\\"
if an exception occured or \\\"<no exception>\\\"
if no exception was raised.
required original--inline-snapshot=create
from inline_snapshot import snapshot\\nfrom inline_snapshot.extra import raises\\n\\n\\ndef test_raises():\\n with raises(snapshot()):\\n 1 / 0\\n
from inline_snapshot import snapshot\\nfrom inline_snapshot.extra import raises\\n\\n\\ndef test_raises():\\n with raises(snapshot(\\\"ZeroDivisionError: division by zero\\\")):\\n 1 / 0\\n
Source code in
.pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/extra.py
@contextlib.contextmanager\\ndef raises(exception: Snapshot[str]):\\n \\\"\\\"\\\"Check that an exception is raised.\\n\\n Parameters:\\n exception: snapshot which is compared with `#!python f\\\"{type}: {message}\\\"` if an exception occured or `#!python \\\"<no exception>\\\"` if no exception was raised.\\n\\n === \\\"original\\\"\\n\\n <!-- inline-snapshot: first_block outcome-passed=1 outcome-errors=1 -->\\n ``` python\\n from inline_snapshot import snapshot\\n from inline_snapshot.extra import raises\\n\\n\\n def test_raises():\\n with raises(snapshot()):\\n 1 / 0\\n ```\\n\\n === \\\"--inline-snapshot=create\\\"\\n\\n <!-- inline-snapshot: create outcome-passed=1 -->\\n ``` python hl_lines=\\\"6\\\"\\n from inline_snapshot import snapshot\\n from inline_snapshot.extra import raises\\n\\n\\n def test_raises():\\n with raises(snapshot(\\\"ZeroDivisionError: division by zero\\\")):\\n 1 / 0\\n ```\\n \\\"\\\"\\\"\\n\\n try:\\n yield\\n except Exception as ex:\\n msg = str(ex)\\n if \\\"\\\\n\\\" in msg:\\n assert f\\\"{type(ex).__name__}:\\\\n{ex}\\\" == exception\\n else:\\n assert f\\\"{type(ex).__name__}: {ex}\\\" == exception\\n else:\\n assert \\\"<no exception>\\\" == exception\\n
\",\n+ \"text\": \"
Check that an exception is raised.
Parameters:
Name Type Description Default
exception
Snapshot[str]
snapshot which is compared with f\\\"{type}: {message}\\\"
if an exception occured or \\\"<no exception>\\\"
if no exception was raised.
required original--inline-snapshot=create
from inline_snapshot import snapshot\\nfrom inline_snapshot.extra import raises\\n\\n\\ndef test_raises():\\n with raises(snapshot()):\\n 1 / 0\\n
from inline_snapshot import snapshot\\nfrom inline_snapshot.extra import raises\\n\\n\\ndef test_raises():\\n with raises(snapshot(\\\"ZeroDivisionError: division by zero\\\")):\\n 1 / 0\\n
Source code in
.pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/extra.py
@contextlib.contextmanager\\ndef raises(exception: Snapshot[str]):\\n \\\"\\\"\\\"Check that an exception is raised.\\n\\n Parameters:\\n exception: snapshot which is compared with `#!python f\\\"{type}: {message}\\\"` if an exception occured or `#!python \\\"<no exception>\\\"` if no exception was raised.\\n\\n === \\\"original\\\"\\n\\n <!-- inline-snapshot: first_block outcome-passed=1 outcome-errors=1 -->\\n ``` python\\n from inline_snapshot import snapshot\\n from inline_snapshot.extra import raises\\n\\n\\n def test_raises():\\n with raises(snapshot()):\\n 1 / 0\\n ```\\n\\n === \\\"--inline-snapshot=create\\\"\\n\\n <!-- inline-snapshot: create outcome-passed=1 -->\\n ``` python hl_lines=\\\"6\\\"\\n from inline_snapshot import snapshot\\n from inline_snapshot.extra import raises\\n\\n\\n def test_raises():\\n with raises(snapshot(\\\"ZeroDivisionError: division by zero\\\")):\\n 1 / 0\\n ```\\n \\\"\\\"\\\"\\n\\n try:\\n yield\\n except Exception as ex:\\n msg = str(ex)\\n if \\\"\\\\n\\\" in msg:\\n assert f\\\"{type(ex).__name__}:\\\\n{ex}\\\" == exception\\n else:\\n assert f\\\"{type(ex).__name__}: {ex}\\\" == exception\\n else:\\n assert \\\"<no exception>\\\" == exception\\n
\",\n \"title\": \"
raises(exception)
\"\n },\n {\n \"location\": \"getitem_snapshot.html\",\n \"text\": \"\",\n \"title\": \"snapshot()[key]\"\n },\n@@ -612,65 +612,65 @@\n {\n \"location\": \"outsource.html#api\",\n \"text\": \"\",\n \"title\": \"API\"\n },\n {\n \"location\": \"outsource.html#inline_snapshot.outsource\",\n- \"text\": \"
Outsource some data into an external file.
>>> png_data = b\\\"some_bytes\\\" # should be the replaced with your actual data\\n>>> outsource(png_data, suffix=\\\".png\\\")\\nexternal(\\\"212974ed1835*.png\\\")\\n
Parameters:
Name Type Description Default
data
Union[str, bytes]
data which should be outsourced. strings are encoded with \\\"utf-8\\\"
.
required
suffix
Optional[str]
overwrite file suffix. The default is \\\".bin\\\"
if data is an instance of bytes
and \\\".txt\\\"
for str
.
None
Returns:
Type Description
external
The external data.
Source code in
.pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/_external.py
def outsource(data: Union[str, bytes], *, suffix: Optional[str] = None) -> external:\\n \\\"\\\"\\\"Outsource some data into an external file.\\n\\n ``` pycon\\n >>> png_data = b\\\"some_bytes\\\" # should be the replaced with your actual data\\n >>> outsource(png_data, suffix=\\\".png\\\")\\n external(\\\"212974ed1835*.png\\\")\\n\\n ```\\n\\n Parameters:\\n data: data which should be outsourced. strings are encoded with `\\\"utf-8\\\"`.\\n\\n suffix: overwrite file suffix. The default is `\\\".bin\\\"` if data is an instance of `#!python bytes` and `\\\".txt\\\"` for `#!python str`.\\n\\n Returns:\\n The external data.\\n \\\"\\\"\\\"\\n if isinstance(data, str):\\n data = data.encode(\\\"utf-8\\\")\\n if suffix is None:\\n suffix = \\\".txt\\\"\\n\\n elif isinstance(data, bytes):\\n if suffix is None:\\n suffix = \\\".bin\\\"\\n else:\\n raise TypeError(\\\"data has to be of type bytes | str\\\")\\n\\n if not suffix or suffix[0] != \\\".\\\":\\n raise ValueError(\\\"suffix has to start with a '.' like '.png'\\\")\\n\\n m = hashlib.sha256()\\n m.update(data)\\n hash = m.hexdigest()\\n\\n assert storage is not None\\n\\n name = hash + suffix\\n\\n if not storage.lookup_all(name):\\n path = hash + \\\"-new\\\" + suffix\\n storage.save(path, data)\\n\\n return external(name)\\n
\",\n+ \"text\": \"
Outsource some data into an external file.
>>> png_data = b\\\"some_bytes\\\" # should be the replaced with your actual data\\n>>> outsource(png_data, suffix=\\\".png\\\")\\nexternal(\\\"212974ed1835*.png\\\")\\n
Parameters:
Name Type Description Default
data
Union[str, bytes]
data which should be outsourced. strings are encoded with \\\"utf-8\\\"
.
required
suffix
Optional[str]
overwrite file suffix. The default is \\\".bin\\\"
if data is an instance of bytes
and \\\".txt\\\"
for str
.
None
Returns:
Type Description
external
The external data.
Source code in
.pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/_external.py
def outsource(data: Union[str, bytes], *, suffix: Optional[str] = None) -> external:\\n \\\"\\\"\\\"Outsource some data into an external file.\\n\\n ``` pycon\\n >>> png_data = b\\\"some_bytes\\\" # should be the replaced with your actual data\\n >>> outsource(png_data, suffix=\\\".png\\\")\\n external(\\\"212974ed1835*.png\\\")\\n\\n ```\\n\\n Parameters:\\n data: data which should be outsourced. strings are encoded with `\\\"utf-8\\\"`.\\n\\n suffix: overwrite file suffix. The default is `\\\".bin\\\"` if data is an instance of `#!python bytes` and `\\\".txt\\\"` for `#!python str`.\\n\\n Returns:\\n The external data.\\n \\\"\\\"\\\"\\n if isinstance(data, str):\\n data = data.encode(\\\"utf-8\\\")\\n if suffix is None:\\n suffix = \\\".txt\\\"\\n\\n elif isinstance(data, bytes):\\n if suffix is None:\\n suffix = \\\".bin\\\"\\n else:\\n raise TypeError(\\\"data has to be of type bytes | str\\\")\\n\\n if not suffix or suffix[0] != \\\".\\\":\\n raise ValueError(\\\"suffix has to start with a '.' like '.png'\\\")\\n\\n m = hashlib.sha256()\\n m.update(data)\\n hash = m.hexdigest()\\n\\n assert storage is not None\\n\\n name = hash + suffix\\n\\n if not storage.lookup_all(name):\\n path = hash + \\\"-new\\\" + suffix\\n storage.save(path, data)\\n\\n return external(name)\\n
\",\n \"title\": \"
inline_snapshot.outsource(data, *, suffix=None)
\"\n },\n {\n \"location\": \"outsource.html#inline_snapshot.external\",\n- \"text\": \"Source code in
.pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/_external.py
class external:\\n def __init__(self, name: str):\\n \\\"\\\"\\\"External objects are used as a representation for outsourced data.\\n You should not create them directly.\\n\\n The external data is stored inside `<pytest_config_dir>/.inline_snapshot/external`,\\n where `<pytest_config_dir>` is replaced by the directory containing the Pytest configuration file, if any.\\n Data which is outsourced but not referenced in the source code jet has a '-new' suffix in the filename.\\n\\n Parameters:\\n name: the name of the external stored object.\\n \\\"\\\"\\\"\\n\\n m = re.fullmatch(r\\\"([0-9a-fA-F]*)\\\\*?(\\\\.[a-zA-Z0-9]*)\\\", name)\\n\\n if m:\\n self._hash, self._suffix = m.groups()\\n else:\\n raise ValueError(\\n \\\"path has to be of the form <hash>.<suffix> or <partial_hash>*.<suffix>\\\"\\n )\\n\\n @property\\n def _path(self):\\n return f\\\"{self._hash}*{self._suffix}\\\"\\n\\n def __repr__(self):\\n \\\"\\\"\\\"Returns the representation of the external object.\\n\\n The length of the hash can be specified in the\\n [config](configuration.md).\\n \\\"\\\"\\\"\\n hash = self._hash[: _config.config.hash_length]\\n\\n if len(hash) == 64:\\n return f'external(\\\"{hash}{self._suffix}\\\")'\\n else:\\n return f'external(\\\"{hash}*{self._suffix}\\\")'\\n\\n def __eq__(self, other):\\n \\\"\\\"\\\"Two external objects are equal if they have the same hash and\\n suffix.\\\"\\\"\\\"\\n if not isinstance(other, external):\\n return NotImplemented\\n\\n min_hash_len = min(len(self._hash), len(other._hash))\\n\\n if self._hash[:min_hash_len] != other._hash[:min_hash_len]:\\n return False\\n\\n if self._suffix != other._suffix:\\n return False\\n\\n return True\\n\\n def _load_value(self):\\n assert storage is not None\\n return storage.read(self._path)\\n
\",\n+ \"text\": \"Source code in
.pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/_external.py
class external:\\n def __init__(self, name: str):\\n \\\"\\\"\\\"External objects are used as a representation for outsourced data.\\n You should not create them directly.\\n\\n The external data is stored inside `<pytest_config_dir>/.inline_snapshot/external`,\\n where `<pytest_config_dir>` is replaced by the directory containing the Pytest configuration file, if any.\\n Data which is outsourced but not referenced in the source code jet has a '-new' suffix in the filename.\\n\\n Parameters:\\n name: the name of the external stored object.\\n \\\"\\\"\\\"\\n\\n m = re.fullmatch(r\\\"([0-9a-fA-F]*)\\\\*?(\\\\.[a-zA-Z0-9]*)\\\", name)\\n\\n if m:\\n self._hash, self._suffix = m.groups()\\n else:\\n raise ValueError(\\n \\\"path has to be of the form <hash>.<suffix> or <partial_hash>*.<suffix>\\\"\\n )\\n\\n @property\\n def _path(self):\\n return f\\\"{self._hash}*{self._suffix}\\\"\\n\\n def __repr__(self):\\n \\\"\\\"\\\"Returns the representation of the external object.\\n\\n The length of the hash can be specified in the\\n [config](configuration.md).\\n \\\"\\\"\\\"\\n hash = self._hash[: _config.config.hash_length]\\n\\n if len(hash) == 64:\\n return f'external(\\\"{hash}{self._suffix}\\\")'\\n else:\\n return f'external(\\\"{hash}*{self._suffix}\\\")'\\n\\n def __eq__(self, other):\\n \\\"\\\"\\\"Two external objects are equal if they have the same hash and\\n suffix.\\\"\\\"\\\"\\n if not isinstance(other, external):\\n return NotImplemented\\n\\n min_hash_len = min(len(self._hash), len(other._hash))\\n\\n if self._hash[:min_hash_len] != other._hash[:min_hash_len]:\\n return False\\n\\n if self._suffix != other._suffix:\\n return False\\n\\n return True\\n\\n def _load_value(self):\\n assert storage is not None\\n return storage.read(self._path)\\n
\",\n \"title\": \"
inline_snapshot.external
\"\n },\n {\n \"location\": \"outsource.html#inline_snapshot.external.__eq__\",\n- \"text\": \"
Two external objects are equal if they have the same hash and suffix.
Source code in
.pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/_external.py
def __eq__(self, other):\\n \\\"\\\"\\\"Two external objects are equal if they have the same hash and\\n suffix.\\\"\\\"\\\"\\n if not isinstance(other, external):\\n return NotImplemented\\n\\n min_hash_len = min(len(self._hash), len(other._hash))\\n\\n if self._hash[:min_hash_len] != other._hash[:min_hash_len]:\\n return False\\n\\n if self._suffix != other._suffix:\\n return False\\n\\n return True\\n
\",\n+ \"text\": \"
Two external objects are equal if they have the same hash and suffix.
Source code in
.pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/_external.py
def __eq__(self, other):\\n \\\"\\\"\\\"Two external objects are equal if they have the same hash and\\n suffix.\\\"\\\"\\\"\\n if not isinstance(other, external):\\n return NotImplemented\\n\\n min_hash_len = min(len(self._hash), len(other._hash))\\n\\n if self._hash[:min_hash_len] != other._hash[:min_hash_len]:\\n return False\\n\\n if self._suffix != other._suffix:\\n return False\\n\\n return True\\n
\",\n \"title\": \"
__eq__(other)
\"\n },\n {\n \"location\": \"outsource.html#inline_snapshot.external.__init__\",\n- \"text\": \"
External objects are used as a representation for outsourced data. You should not create them directly.
The external data is stored inside <pytest_config_dir>/.inline_snapshot/external
, where <pytest_config_dir>
is replaced by the directory containing the Pytest configuration file, if any. Data which is outsourced but not referenced in the source code jet has a '-new' suffix in the filename.
Parameters:
Name Type Description Default
name
str
the name of the external stored object.
required Source code in
.pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/_external.py
def __init__(self, name: str):\\n \\\"\\\"\\\"External objects are used as a representation for outsourced data.\\n You should not create them directly.\\n\\n The external data is stored inside `<pytest_config_dir>/.inline_snapshot/external`,\\n where `<pytest_config_dir>` is replaced by the directory containing the Pytest configuration file, if any.\\n Data which is outsourced but not referenced in the source code jet has a '-new' suffix in the filename.\\n\\n Parameters:\\n name: the name of the external stored object.\\n \\\"\\\"\\\"\\n\\n m = re.fullmatch(r\\\"([0-9a-fA-F]*)\\\\*?(\\\\.[a-zA-Z0-9]*)\\\", name)\\n\\n if m:\\n self._hash, self._suffix = m.groups()\\n else:\\n raise ValueError(\\n \\\"path has to be of the form <hash>.<suffix> or <partial_hash>*.<suffix>\\\"\\n )\\n
\",\n+ \"text\": \"
External objects are used as a representation for outsourced data. You should not create them directly.
The external data is stored inside <pytest_config_dir>/.inline_snapshot/external
, where <pytest_config_dir>
is replaced by the directory containing the Pytest configuration file, if any. Data which is outsourced but not referenced in the source code jet has a '-new' suffix in the filename.
Parameters:
Name Type Description Default
name
str
the name of the external stored object.
required Source code in
.pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/_external.py
def __init__(self, name: str):\\n \\\"\\\"\\\"External objects are used as a representation for outsourced data.\\n You should not create them directly.\\n\\n The external data is stored inside `<pytest_config_dir>/.inline_snapshot/external`,\\n where `<pytest_config_dir>` is replaced by the directory containing the Pytest configuration file, if any.\\n Data which is outsourced but not referenced in the source code jet has a '-new' suffix in the filename.\\n\\n Parameters:\\n name: the name of the external stored object.\\n \\\"\\\"\\\"\\n\\n m = re.fullmatch(r\\\"([0-9a-fA-F]*)\\\\*?(\\\\.[a-zA-Z0-9]*)\\\", name)\\n\\n if m:\\n self._hash, self._suffix = m.groups()\\n else:\\n raise ValueError(\\n \\\"path has to be of the form <hash>.<suffix> or <partial_hash>*.<suffix>\\\"\\n )\\n
\",\n \"title\": \"
__init__(name)
\"\n },\n {\n \"location\": \"outsource.html#inline_snapshot.external.__repr__\",\n- \"text\": \"
Returns the representation of the external object.
The length of the hash can be specified in the config.
Source code in
.pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/_external.py
def __repr__(self):\\n \\\"\\\"\\\"Returns the representation of the external object.\\n\\n The length of the hash can be specified in the\\n [config](configuration.md).\\n \\\"\\\"\\\"\\n hash = self._hash[: _config.config.hash_length]\\n\\n if len(hash) == 64:\\n return f'external(\\\"{hash}{self._suffix}\\\")'\\n else:\\n return f'external(\\\"{hash}*{self._suffix}\\\")'\\n
\",\n+ \"text\": \"
Returns the representation of the external object.
The length of the hash can be specified in the config.
Source code in
.pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/_external.py
def __repr__(self):\\n \\\"\\\"\\\"Returns the representation of the external object.\\n\\n The length of the hash can be specified in the\\n [config](configuration.md).\\n \\\"\\\"\\\"\\n hash = self._hash[: _config.config.hash_length]\\n\\n if len(hash) == 64:\\n return f'external(\\\"{hash}{self._suffix}\\\")'\\n else:\\n return f'external(\\\"{hash}*{self._suffix}\\\")'\\n
\",\n \"title\": \"
__repr__()
\"\n },\n {\n \"location\": \"outsource.html#pytest-options\",\n \"text\": \"
It interacts with the following --inline-snapshot
flags:
trim
removes every snapshots form the storage which is not referenced with external(...)
in the code.
\",\n \"title\": \"pytest options\"\n },\n {\n \"location\": \"pytest.html\",\n \"text\": \"
inline-snapshot provides one pytest option with different flags (create, fix, trim, update, short-report, report, disable).
Snapshot comparisons return always True
if you use one of the flags create, fix or review. This is necessary because the whole test needs to be run to fix all snapshots like in this case:
from inline_snapshot import snapshot\\n\\n\\ndef test_something():\\n assert 1 == snapshot(5)\\n assert 2 <= snapshot(5)\\n
Note
Every flag with the exception of disable and short-report disables the pytest assert-rewriting.
\",\n \"title\": \"pytest integration\"\n },\n {\n \"location\": \"pytest.html#-inline-snapshotcreatefixtrimupdate\",\n- \"text\": \"
Approve the changes of the given category. These flags can be combined with report and review.
test_something.py
from inline_snapshot import snapshot\\n\\n\\ndef test_something():\\n assert 1 == snapshot()\\n assert 2 <= snapshot(5)\\n
\\u001b[1;34m> pytest test_something.py --inline-snapshot=create,report\\n\\u001b[0m\\u001b[1m============================= test session starts ==============================\\u001b[0m\\nplatform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0\\nrootdir: /tmp/tmp.CETKrEZFtC\\nplugins: pytest_freezer-0.4.8, hypothesis-6.122.1, typeguard-4.4.1, time-machine-2.14.1, subtests-0.13.1, inline-snapshot-0.14.0\\ncollected 1 item\\n\\ntest_something.py \\u001b[32m.\\u001b[0m\\u001b[32m [100%]\\u001b[0m\\n=============================== inline snapshot ================================\\n\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 Create snapshots \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\n+----------------------------- test_something.py ------------------------------+\\n| @@ -2,5 +2,5 @@ |\\n| |\\n| |\\n| |\\n| def test_something(): |\\n| - assert 1 == snapshot() |\\n| + assert 1 == snapshot(1) |\\n| assert 2 <= snapshot(5) |\\n+------------------------------------------------------------------------------+\\nThese changes will be applied, because you used --inline-snapshot=create\\n\\n\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 Trim snapshots \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\n+----------------------------- test_something.py ------------------------------+\\n| @@ -3,4 +3,4 @@ |\\n| |\\n| |\\n| def test_something(): |\\n| assert 1 == snapshot(1) |\\n| - assert 2 <= snapshot(5) |\\n| + assert 2 <= snapshot(2) |\\n+------------------------------------------------------------------------------+\\nThese changes are not applied.\\nUse --inline-snapshot=trim to apply them, or use the interactive mode with \\n--inline-snapshot=review\\n\\n\\n\\u001b[32m============================== \\u001b[32m\\u001b[1m1 passed\\u001b[0m\\u001b[32m in 0.16s\\u001b[0m\\u001b[32m ===============================\\u001b[0m\\n
\",\n+ \"text\": \"
Approve the changes of the given category. These flags can be combined with report and review.
test_something.py
from inline_snapshot import snapshot\\n\\n\\ndef test_something():\\n assert 1 == snapshot()\\n assert 2 <= snapshot(5)\\n
\\u001b[1;34m> pytest test_something.py --inline-snapshot=create,report\\n\\u001b[0m\\u001b[1m============================= test session starts ==============================\\u001b[0m\\nplatform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0\\nrootdir: /tmp/tmp.Wt1lijWNCQ\\nplugins: hypothesis-6.122.1, typeguard-4.4.1, inline-snapshot-0.14.0, time-machine-2.14.1, subtests-0.13.1, pytest_freezer-0.4.8\\ncollected 1 item\\n\\ntest_something.py \\u001b[32m.\\u001b[0m\\u001b[32m [100%]\\u001b[0m\\n=============================== inline snapshot ================================\\n\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 Create snapshots \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\n+----------------------------- test_something.py ------------------------------+\\n| @@ -2,5 +2,5 @@ |\\n| |\\n| |\\n| |\\n| def test_something(): |\\n| - assert 1 == snapshot() |\\n| + assert 1 == snapshot(1) |\\n| assert 2 <= snapshot(5) |\\n+------------------------------------------------------------------------------+\\nThese changes will be applied, because you used --inline-snapshot=create\\n\\n\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 Trim snapshots \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\n+----------------------------- test_something.py ------------------------------+\\n| @@ -3,4 +3,4 @@ |\\n| |\\n| |\\n| def test_something(): |\\n| assert 1 == snapshot(1) |\\n| - assert 2 <= snapshot(5) |\\n| + assert 2 <= snapshot(2) |\\n+------------------------------------------------------------------------------+\\nThese changes are not applied.\\nUse --inline-snapshot=trim to apply them, or use the interactive mode with \\n--inline-snapshot=review\\n\\n\\n\\u001b[32m============================== \\u001b[32m\\u001b[1m1 passed\\u001b[0m\\u001b[32m in 0.11s\\u001b[0m\\u001b[32m ===============================\\u001b[0m\\n
\",\n \"title\": \"--inline-snapshot=create,fix,trim,update\"\n },\n {\n \"location\": \"pytest.html#-inline-snapshotshort-report\",\n- \"text\": \"
give a short report over which changes can be made to the snapshots
\\u001b[1;34m> pytest test_something.py --inline-snapshot=short-report\\n\\u001b[0m\\u001b[1m============================= test session starts ==============================\\u001b[0m\\nplatform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0\\nrootdir: /tmp/tmp.OH39pszdwB\\nplugins: pytest_freezer-0.4.8, hypothesis-6.122.1, typeguard-4.4.1, time-machine-2.14.1, subtests-0.13.1, inline-snapshot-0.14.0\\ncollected 1 item\\n\\ntest_something.py \\u001b[32m.\\u001b[0m\\u001b[31mE\\u001b[0m\\u001b[31m [100%]\\u001b[0m\\n\\n==================================== ERRORS ====================================\\n\\u001b[31m\\u001b[1m_____________________ ERROR at teardown of test_something ______________________\\u001b[0m\\n\\u001b[0myour snapshot \\u001b[95mis\\u001b[39;49;00m missing one value.\\u001b[90m\\u001b[39;49;00m\\n=============================== inline snapshot ================================\\nInfo: one snapshot can be trimmed (--inline-snapshot=trim)\\nError: one snapshot is missing a value (--inline-snapshot=create)\\n\\nYou can also use --inline-snapshot=review to approve the changes interactively\\n\\u001b[36m\\u001b[1m=========================== short test summary info ============================\\u001b[0m\\n\\u001b[31mERROR\\u001b[0m test_something.py::\\u001b[1mtest_something\\u001b[0m - Failed: your snapshot is missing one value.\\n\\u001b[31m========================== \\u001b[32m1 passed\\u001b[0m, \\u001b[31m\\u001b[1m1 error\\u001b[0m\\u001b[31m in 0.16s\\u001b[0m\\u001b[31m ==========================\\u001b[0m\\n
Info
short-report exists mainly to show that snapshots have changed with enabled pytest assert-rewriting. This option will be replaced with report when this restriction is lifted.
\",\n+ \"text\": \"
give a short report over which changes can be made to the snapshots
\\u001b[1;34m> pytest test_something.py --inline-snapshot=short-report\\n\\u001b[0m\\u001b[1m============================= test session starts ==============================\\u001b[0m\\nplatform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0\\nrootdir: /tmp/tmp.78DgZaOzgR\\nplugins: hypothesis-6.122.1, typeguard-4.4.1, inline-snapshot-0.14.0, time-machine-2.14.1, subtests-0.13.1, pytest_freezer-0.4.8\\ncollected 1 item\\n\\ntest_something.py \\u001b[32m.\\u001b[0m\\u001b[31mE\\u001b[0m\\u001b[31m [100%]\\u001b[0m\\n\\n==================================== ERRORS ====================================\\n\\u001b[31m\\u001b[1m_____________________ ERROR at teardown of test_something ______________________\\u001b[0m\\n\\u001b[0myour snapshot \\u001b[95mis\\u001b[39;49;00m missing one value.\\u001b[90m\\u001b[39;49;00m\\n=============================== inline snapshot ================================\\nInfo: one snapshot can be trimmed (--inline-snapshot=trim)\\nError: one snapshot is missing a value (--inline-snapshot=create)\\n\\nYou can also use --inline-snapshot=review to approve the changes interactively\\n\\u001b[36m\\u001b[1m=========================== short test summary info ============================\\u001b[0m\\n\\u001b[31mERROR\\u001b[0m test_something.py::\\u001b[1mtest_something\\u001b[0m - Failed: your snapshot is missing one value.\\n\\u001b[31m========================== \\u001b[32m1 passed\\u001b[0m, \\u001b[31m\\u001b[1m1 error\\u001b[0m\\u001b[31m in 0.13s\\u001b[0m\\u001b[31m ==========================\\u001b[0m\\n
Info
short-report exists mainly to show that snapshots have changed with enabled pytest assert-rewriting. This option will be replaced with report when this restriction is lifted.
\",\n \"title\": \"--inline-snapshot=short-report\"\n },\n {\n \"location\": \"pytest.html#-inline-snapshotreport\",\n- \"text\": \"
Shows a diff report over which changes can be made to the snapshots
\\u001b[1;34m> pytest test_something.py --inline-snapshot=report\\n\\u001b[0m\\u001b[1m============================= test session starts ==============================\\u001b[0m\\nplatform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0\\nrootdir: /tmp/tmp.uRkCyvpEg8\\nplugins: pytest_freezer-0.4.8, hypothesis-6.122.1, typeguard-4.4.1, time-machine-2.14.1, subtests-0.13.1, inline-snapshot-0.14.0\\ncollected 1 item\\n\\ntest_something.py \\u001b[32m.\\u001b[0m\\u001b[31mE\\u001b[0m\\u001b[31m [100%]\\u001b[0m\\n\\n==================================== ERRORS ====================================\\n\\u001b[31m\\u001b[1m_____________________ ERROR at teardown of test_something ______________________\\u001b[0m\\n\\u001b[0myour snapshot \\u001b[95mis\\u001b[39;49;00m missing one value.\\u001b[90m\\u001b[39;49;00m\\n=============================== inline snapshot ================================\\n\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 Create snapshots \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\n+----------------------------- test_something.py ------------------------------+\\n| @@ -2,5 +2,5 @@ |\\n| |\\n| |\\n| |\\n| def test_something(): |\\n| - assert 1 == snapshot() |\\n| + assert 1 == snapshot(1) |\\n| assert 2 <= snapshot(5) |\\n+------------------------------------------------------------------------------+\\nThese changes are not applied.\\nUse --inline-snapshot=create to apply them, or use the interactive mode with \\n--inline-snapshot=review\\n\\n\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 Trim snapshots \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\n+----------------------------- test_something.py ------------------------------+\\n| @@ -3,4 +3,4 @@ |\\n| |\\n| |\\n| def test_something(): |\\n| assert 1 == snapshot() |\\n| - assert 2 <= snapshot(5) |\\n| + assert 2 <= snapshot(2) |\\n+------------------------------------------------------------------------------+\\nThese changes are not applied.\\nUse --inline-snapshot=trim to apply them, or use the interactive mode with \\n--inline-snapshot=review\\n\\n\\u001b[36m\\u001b[1m=========================== short test summary info ============================\\u001b[0m\\n\\u001b[31mERROR\\u001b[0m test_something.py::\\u001b[1mtest_something\\u001b[0m - Failed: your snapshot is missing one value.\\n\\u001b[31m========================== \\u001b[32m1 passed\\u001b[0m, \\u001b[31m\\u001b[1m1 error\\u001b[0m\\u001b[31m in 0.18s\\u001b[0m\\u001b[31m ==========================\\u001b[0m\\n
\",\n+ \"text\": \"
Shows a diff report over which changes can be made to the snapshots
\\u001b[1;34m> pytest test_something.py --inline-snapshot=report\\n\\u001b[0m\\u001b[1m============================= test session starts ==============================\\u001b[0m\\nplatform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0\\nrootdir: /tmp/tmp.BAEOfeFGMp\\nplugins: hypothesis-6.122.1, typeguard-4.4.1, inline-snapshot-0.14.0, time-machine-2.14.1, subtests-0.13.1, pytest_freezer-0.4.8\\ncollected 1 item\\n\\ntest_something.py \\u001b[32m.\\u001b[0m\\u001b[31mE\\u001b[0m\\u001b[31m [100%]\\u001b[0m\\n\\n==================================== ERRORS ====================================\\n\\u001b[31m\\u001b[1m_____________________ ERROR at teardown of test_something ______________________\\u001b[0m\\n\\u001b[0myour snapshot \\u001b[95mis\\u001b[39;49;00m missing one value.\\u001b[90m\\u001b[39;49;00m\\n=============================== inline snapshot ================================\\n\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 Create snapshots \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\n+----------------------------- test_something.py ------------------------------+\\n| @@ -2,5 +2,5 @@ |\\n| |\\n| |\\n| |\\n| def test_something(): |\\n| - assert 1 == snapshot() |\\n| + assert 1 == snapshot(1) |\\n| assert 2 <= snapshot(5) |\\n+------------------------------------------------------------------------------+\\nThese changes are not applied.\\nUse --inline-snapshot=create to apply them, or use the interactive mode with \\n--inline-snapshot=review\\n\\n\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 Trim snapshots \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\n+----------------------------- test_something.py ------------------------------+\\n| @@ -3,4 +3,4 @@ |\\n| |\\n| |\\n| def test_something(): |\\n| assert 1 == snapshot() |\\n| - assert 2 <= snapshot(5) |\\n| + assert 2 <= snapshot(2) |\\n+------------------------------------------------------------------------------+\\nThese changes are not applied.\\nUse --inline-snapshot=trim to apply them, or use the interactive mode with \\n--inline-snapshot=review\\n\\n\\u001b[36m\\u001b[1m=========================== short test summary info ============================\\u001b[0m\\n\\u001b[31mERROR\\u001b[0m test_something.py::\\u001b[1mtest_something\\u001b[0m - Failed: your snapshot is missing one value.\\n\\u001b[31m========================== \\u001b[32m1 passed\\u001b[0m, \\u001b[31m\\u001b[1m1 error\\u001b[0m\\u001b[31m in 0.21s\\u001b[0m\\u001b[31m ==========================\\u001b[0m\\n
\",\n \"title\": \"--inline-snapshot=report\"\n },\n {\n \"location\": \"pytest.html#-inline-snapshotreview\",\n- \"text\": \"
Shows a diff report for each category and ask if you want to apply the changes
\\u001b[1;34m> pytest test_something.py --inline-snapshot=review\\n\\u001b[0m\\u001b[1m============================= test session starts ==============================\\u001b[0m\\nplatform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0\\nrootdir: /tmp/tmp.hpELK540k1\\nplugins: pytest_freezer-0.4.8, hypothesis-6.122.1, typeguard-4.4.1, time-machine-2.14.1, subtests-0.13.1, inline-snapshot-0.14.0\\ncollected 1 item\\n\\ntest_something.py \\u001b[32m.\\u001b[0m\\u001b[32m [100%]\\u001b[0m\\n=============================== inline snapshot ================================\\n\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 Create snapshots \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\n+----------------------------- test_something.py ------------------------------+\\n| @@ -2,5 +2,5 @@ |\\n| |\\n| |\\n| |\\n| def test_something(): |\\n| - assert 1 == snapshot() |\\n| + assert 1 == snapshot(1) |\\n| assert 2 <= snapshot(5) |\\n+------------------------------------------------------------------------------+\\ndo you want to create these snapshots? [y/n] (n): \\n\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 Trim snapshots \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\n+----------------------------- test_something.py ------------------------------+\\n| @@ -3,4 +3,4 @@ |\\n| |\\n| |\\n| def test_something(): |\\n| assert 1 == snapshot(1) |\\n| - assert 2 <= snapshot(5) |\\n| + assert 2 <= snapshot(2) |\\n+------------------------------------------------------------------------------+\\ndo you want to trim these snapshots? [y/n] (n): \\n\\n\\u001b[32m============================== \\u001b[32m\\u001b[1m1 passed\\u001b[0m\\u001b[32m in 0.23s\\u001b[0m\\u001b[32m ===============================\\u001b[0m\\n
\",\n+ \"text\": \"
Shows a diff report for each category and ask if you want to apply the changes
\\u001b[1;34m> pytest test_something.py --inline-snapshot=review\\n\\u001b[0m\\u001b[1m============================= test session starts ==============================\\u001b[0m\\nplatform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0\\nrootdir: /tmp/tmp.y5TdogDd7R\\nplugins: hypothesis-6.122.1, typeguard-4.4.1, inline-snapshot-0.14.0, time-machine-2.14.1, subtests-0.13.1, pytest_freezer-0.4.8\\ncollected 1 item\\n\\ntest_something.py \\u001b[32m.\\u001b[0m\\u001b[32m [100%]\\u001b[0m\\n=============================== inline snapshot ================================\\n\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 Create snapshots \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\n+----------------------------- test_something.py ------------------------------+\\n| @@ -2,5 +2,5 @@ |\\n| |\\n| |\\n| |\\n| def test_something(): |\\n| - assert 1 == snapshot() |\\n| + assert 1 == snapshot(1) |\\n| assert 2 <= snapshot(5) |\\n+------------------------------------------------------------------------------+\\ndo you want to create these snapshots? [y/n] (n): \\n\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 Trim snapshots \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\n+----------------------------- test_something.py ------------------------------+\\n| @@ -3,4 +3,4 @@ |\\n| |\\n| |\\n| def test_something(): |\\n| assert 1 == snapshot(1) |\\n| - assert 2 <= snapshot(5) |\\n| + assert 2 <= snapshot(2) |\\n+------------------------------------------------------------------------------+\\ndo you want to trim these snapshots? [y/n] (n): \\n\\n\\u001b[32m============================== \\u001b[32m\\u001b[1m1 passed\\u001b[0m\\u001b[32m in 0.19s\\u001b[0m\\u001b[32m ===============================\\u001b[0m\\n
\",\n \"title\": \"--inline-snapshot=review\"\n },\n {\n \"location\": \"pytest.html#-inline-snapshotdisable\",\n \"text\": \"
Disables all the snapshot logic. snapshot(x)
will just return x
. This can be used if you think exclude that snapshot logic causes a problem in your tests, or if you want to speedup your CI.
deprecation
This option was previously called --inline-snapshot-disable
\",\n \"title\": \"--inline-snapshot=disable\"\n },\n@@ -722,12 +722,12 @@\n {\n \"location\": \"types.html#inline_snapshot.Category\",\n \"text\": \"
See categories
\",\n \"title\": \"
Category = Literal['update', 'fix', 'create', 'trim']
module-attribute
\"\n },\n {\n \"location\": \"types.html#inline_snapshot.Snapshot\",\n- \"text\": \"
Can be used to annotate function arguments which accept snapshot values.
You can annotate function arguments with Snapshot[T]
to declare that a snapshot-value can be passed as function argument. Snapshot[T]
is a type alias for T
, which allows you to pass int
values instead of int
snapshots.
Example:
from typing import Optional\\nfrom inline_snapshot import snapshot, Snapshot\\n\\n# required snapshots\\n\\n\\ndef check_in_bounds(value, lower: Snapshot[int], upper: Snapshot[int]):\\n assert lower <= value <= upper\\n\\n\\ndef test_numbers():\\n for c in \\\"hello world\\\":\\n check_in_bounds(ord(c), snapshot(32), snapshot(119))\\n\\n # use with normal values\\n check_in_bounds(5, 0, 10)\\n\\n\\n# optional snapshots\\n\\n\\ndef check_container(\\n value,\\n *,\\n value_repr: Optional[Snapshot[str]] = None,\\n length: Optional[Snapshot[int]] = None\\n):\\n if value_repr is not None:\\n assert repr(value) == value_repr\\n\\n if length is not None:\\n assert len(value) == length\\n\\n\\ndef test_container():\\n check_container([1, 2], value_repr=snapshot(\\\"[1, 2]\\\"), length=snapshot(2))\\n\\n check_container({1, 1}, length=snapshot(1))\\n
Source code in
.pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/_types.py
class Snapshot(Generic[T]):\\n \\\"\\\"\\\"Can be used to annotate function arguments which accept snapshot\\n values.\\n\\n You can annotate function arguments with `Snapshot[T]` to declare that a snapshot-value can be passed as function argument.\\n `Snapshot[T]` is a type alias for `T`, which allows you to pass `int` values instead of `int` snapshots.\\n\\n\\n Example:\\n <!-- inline-snapshot: create fix trim first_block outcome-passed=2 -->\\n ``` python\\n from typing import Optional\\n from inline_snapshot import snapshot, Snapshot\\n\\n # required snapshots\\n\\n\\n def check_in_bounds(value, lower: Snapshot[int], upper: Snapshot[int]):\\n assert lower <= value <= upper\\n\\n\\n def test_numbers():\\n for c in \\\"hello world\\\":\\n check_in_bounds(ord(c), snapshot(32), snapshot(119))\\n\\n # use with normal values\\n check_in_bounds(5, 0, 10)\\n\\n\\n # optional snapshots\\n\\n\\n def check_container(\\n value,\\n *,\\n value_repr: Optional[Snapshot[str]] = None,\\n length: Optional[Snapshot[int]] = None\\n ):\\n if value_repr is not None:\\n assert repr(value) == value_repr\\n\\n if length is not None:\\n assert len(value) == length\\n\\n\\n def test_container():\\n check_container([1, 2], value_repr=snapshot(\\\"[1, 2]\\\"), length=snapshot(2))\\n\\n check_container({1, 1}, length=snapshot(1))\\n ```\\n \\\"\\\"\\\"\\n
\",\n+ \"text\": \"
Can be used to annotate function arguments which accept snapshot values.
You can annotate function arguments with Snapshot[T]
to declare that a snapshot-value can be passed as function argument. Snapshot[T]
is a type alias for T
, which allows you to pass int
values instead of int
snapshots.
Example:
from typing import Optional\\nfrom inline_snapshot import snapshot, Snapshot\\n\\n# required snapshots\\n\\n\\ndef check_in_bounds(value, lower: Snapshot[int], upper: Snapshot[int]):\\n assert lower <= value <= upper\\n\\n\\ndef test_numbers():\\n for c in \\\"hello world\\\":\\n check_in_bounds(ord(c), snapshot(32), snapshot(119))\\n\\n # use with normal values\\n check_in_bounds(5, 0, 10)\\n\\n\\n# optional snapshots\\n\\n\\ndef check_container(\\n value,\\n *,\\n value_repr: Optional[Snapshot[str]] = None,\\n length: Optional[Snapshot[int]] = None\\n):\\n if value_repr is not None:\\n assert repr(value) == value_repr\\n\\n if length is not None:\\n assert len(value) == length\\n\\n\\ndef test_container():\\n check_container([1, 2], value_repr=snapshot(\\\"[1, 2]\\\"), length=snapshot(2))\\n\\n check_container({1, 1}, length=snapshot(1))\\n
Source code in
.pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/_types.py
class Snapshot(Generic[T]):\\n \\\"\\\"\\\"Can be used to annotate function arguments which accept snapshot\\n values.\\n\\n You can annotate function arguments with `Snapshot[T]` to declare that a snapshot-value can be passed as function argument.\\n `Snapshot[T]` is a type alias for `T`, which allows you to pass `int` values instead of `int` snapshots.\\n\\n\\n Example:\\n <!-- inline-snapshot: create fix trim first_block outcome-passed=2 -->\\n ``` python\\n from typing import Optional\\n from inline_snapshot import snapshot, Snapshot\\n\\n # required snapshots\\n\\n\\n def check_in_bounds(value, lower: Snapshot[int], upper: Snapshot[int]):\\n assert lower <= value <= upper\\n\\n\\n def test_numbers():\\n for c in \\\"hello world\\\":\\n check_in_bounds(ord(c), snapshot(32), snapshot(119))\\n\\n # use with normal values\\n check_in_bounds(5, 0, 10)\\n\\n\\n # optional snapshots\\n\\n\\n def check_container(\\n value,\\n *,\\n value_repr: Optional[Snapshot[str]] = None,\\n length: Optional[Snapshot[int]] = None\\n ):\\n if value_repr is not None:\\n assert repr(value) == value_repr\\n\\n if length is not None:\\n assert len(value) == length\\n\\n\\n def test_container():\\n check_container([1, 2], value_repr=snapshot(\\\"[1, 2]\\\"), length=snapshot(2))\\n\\n check_container({1, 1}, length=snapshot(1))\\n ```\\n \\\"\\\"\\\"\\n
\",\n \"title\": \"
Snapshot
\"\n }\n ]\n }\n"}]}, {"source1": "./usr/share/doc/python-inline-snapshot-doc/html/types.html", "source2": "./usr/share/doc/python-inline-snapshot-doc/html/types.html", "unified_diff": "@@ -1001,15 +1001,15 @@\n \n \n \n \n \n \n
\n- Source code in .pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/_types.py
\n+ Source code in .pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/_types.py
\n 21\n 22\n 23\n 24\n 25\n 26\n 27\n", "details": [{"source1": "html2text {}", "source2": "html2text {}", "unified_diff": "@@ -78,15 +78,15 @@\n assert len(value) == length\n \n \n def test_container():\n check_container([1, 2], value_repr=snapshot(\"[1, 2]\"), length=snapshot(2))\n \n check_container({1, 1}, length=snapshot(1))\n-Source code in .pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/\n+Source code in .pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/\n _types.py\n class Snapshot(Generic[T]):\n _\b2_\b1 \"\"\"Can be used to annotate function arguments which accept snapshot\n _\b2_\b2 values.\n _\b2_\b3\n _\b2_\b4 You can annotate function arguments with `Snapshot[T]` to declare that a\n _\b2_\b5 snapshot-value can be passed as function argument.\n"}]}]}]}]}]}
|