| | | |
Offset 672, 25 lines modified | Offset 672, 25 lines modified |
672 | ········{ | 672 | ········{ |
673 | ············"location":·"extra.html#inline_snapshot.extra", | 673 | ············"location":·"extra.html#inline_snapshot.extra", |
674 | ············"text":·"<p>The·following·functions·are·build·on·top·of·inline-snapshot·and·could·also·be·implemented·in·an·extra·library.</p>·<p>They·are·part·of·inline-snapshot·because·they·are·general·useful·and·do·not·depend·on·other·libraries.</p>", | 674 | ············"text":·"<p>The·following·functions·are·build·on·top·of·inline-snapshot·and·could·also·be·implemented·in·an·extra·library.</p>·<p>They·are·part·of·inline-snapshot·because·they·are·general·useful·and·do·not·depend·on·other·libraries.</p>", |
675 | ············"title":·"<code>inline_snapshot.extra</code>" | 675 | ············"title":·"<code>inline_snapshot.extra</code>" |
676 | ········}, | 676 | ········}, |
677 | ········{ | 677 | ········{ |
678 | ············"location":·"extra.html#inline_snapshot.extra.prints", | 678 | ············"location":·"extra.html#inline_snapshot.extra.prints", |
679 | ············"text":·"<p>Uses·<code>contextlib.redirect_stderr/stdout</code>·to·capture·the·output·and·compare·it·with·the·snapshots.·<code>dirty_equals.IsStr</code>·can·be·used·to·ignore·the·output·if·needed.</p>·<p>Parameters:</p>·Name·Type·Description·Default·<code>stdout</code>·<code>Snapshot[str]</code>·<p>snapshot·which·is·compared·to·the·recorded·output</p>·<code>''</code>·<code>stderr</code>·<code>Snapshot[str]</code>·<p>snapshot·which·is·compared·to·the·recorded·error·output</p>·<code>''</code>·original--inline-snapshot=createignore·stdout·<p>·<pre><code>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</code></pre></p>·<p>·<pre><code>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</code></pre></p>·<p>·<pre><code>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</code></pre></p>·Source·code·in·<code>.pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/extra.py</code>·<pre><code>@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</code></pre>", | 679 | ············"text":·"<p>Uses·<code>contextlib.redirect_stderr/stdout</code>·to·capture·the·output·and·compare·it·with·the·snapshots.·<code>dirty_equals.IsStr</code>·can·be·used·to·ignore·the·output·if·needed.</p>·<p>Parameters:</p>·Name·Type·Description·Default·<code>stdout</code>·<code>Snapshot[str]</code>·<p>snapshot·which·is·compared·to·the·recorded·output</p>·<code>''</code>·<code>stderr</code>·<code>Snapshot[str]</code>·<p>snapshot·which·is·compared·to·the·recorded·error·output</p>·<code>''</code>·original--inline-snapshot=createignore·stdout·<p>·<pre><code>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</code></pre></p>·<p>·<pre><code>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</code></pre></p>·<p>·<pre><code>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</code></pre></p>·Source·code·in·<code>.pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/extra.py</code>·<pre><code>@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</code></pre>", |
680 | ············"title":·"<code>prints(*,·stdout='',·stderr='')</code>" | 680 | ············"title":·"<code>prints(*,·stdout='',·stderr='')</code>" |
681 | ········}, | 681 | ········}, |
682 | ········{ | 682 | ········{ |
683 | ············"location":·"extra.html#inline_snapshot.extra.raises", | 683 | ············"location":·"extra.html#inline_snapshot.extra.raises", |
684 | ············"text":·"<p>Check·that·an·exception·is·raised.</p>·<p>Parameters:</p>·Name·Type·Description·Default·<code>exception</code>·<code>Snapshot[str]</code>·<p>snapshot·which·is·compared·with·<code>f\"{type}:·{message}\"</code>·if·an·exception·occured·or·<code>\"<no·exception>\"</code>·if·no·exception·was·raised.</p>·required·original--inline-snapshot=create·<p>·<pre><code>from·inline_snapshot·import·snapshot\nfrom·inline_snapshot.extra·import·raises\n\n\ndef·test_raises():\n····with·raises(snapshot()):\n········1·/·0\n</code></pre></p>·<p>·<pre><code>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</code></pre></p>·Source·code·in·<code>.pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/extra.py</code>·<pre><code>@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</code></pre>", | 684 | ············"text":·"<p>Check·that·an·exception·is·raised.</p>·<p>Parameters:</p>·Name·Type·Description·Default·<code>exception</code>·<code>Snapshot[str]</code>·<p>snapshot·which·is·compared·with·<code>f\"{type}:·{message}\"</code>·if·an·exception·occured·or·<code>\"<no·exception>\"</code>·if·no·exception·was·raised.</p>·required·original--inline-snapshot=create·<p>·<pre><code>from·inline_snapshot·import·snapshot\nfrom·inline_snapshot.extra·import·raises\n\n\ndef·test_raises():\n····with·raises(snapshot()):\n········1·/·0\n</code></pre></p>·<p>·<pre><code>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</code></pre></p>·Source·code·in·<code>.pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/extra.py</code>·<pre><code>@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</code></pre>", |
685 | ············"title":·"<code>raises(exception)</code>" | 685 | ············"title":·"<code>raises(exception)</code>" |
686 | ········}, | 686 | ········}, |
687 | ········{ | 687 | ········{ |
688 | ············"location":·"extra.html#inline_snapshot.extra.warns", | 688 | ············"location":·"extra.html#inline_snapshot.extra.warns", |
689 | ············"text":·"<p>Captures·warnings·with·<code>warnings.catch_warnings</code>·and·compares·them·against·expected·warnings.</p>·<p>Parameters:</p>·Name·Type·Description·Default·<code>expected_warnings</code>·<code>Snapshot[List[Warning]]</code>·<p>Snapshot·containing·a·list·of·expected·warnings.</p>·required·<code>include_line</code>·<code>bool</code>·<p>If·<code>True</code>,·each·expected·warning·is·a·tuple·<code>(linenumber,·message)</code>.</p>·<code>False</code>·<code>include_file</code>·<code>bool</code>·<p>If·<code>True</code>,·each·expected·warning·is·a·tuple·<code>(filename,·message)</code>.</p>·<code>False</code>·<p>The·format·of·the·expected·warning:</p>·<ul>·<li><code>(filename,·linenumber,·message)</code>·if·both·<code>include_line</code>·and·<code>include_file</code>·are·<code>True</code>.</li>·<li><code>(linenumber,·message)</code>·if·only·<code>include_line</code>·is·<code>True</code>.</li>·<li><code>(filename,·message)</code>·if·only·<code>include_file</code>·is·<code>True</code>.</li>·<li>A·string·<code>message</code>·if·both·are·<code>False</code>.</li>·</ul>·original--inline-snapshot=create·<p>·<pre><code>from·inline_snapshot·import·snapshot\nfrom·inline_snapshot.extra·import·warns\nfrom·warnings·import·warn\n\n\ndef·test_warns():\n····with·warns(snapshot(),·include_line=True):\n········warn(\"some·problem\")\n</code></pre></p>·<p>·<pre><code>from·inline_snapshot·import·snapshot\nfrom·inline_snapshot.extra·import·warns\nfrom·warnings·import·warn\n\n\ndef·test_warns():\n····with·warns(snapshot([(8,·\"UserWarning:·some·problem\")]),·include_line=True):\n········warn(\"some·problem\")\n</code></pre></p>·Source·code·in·<code>.pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/extra.py</code>·<pre><code>@contextlib.contextmanager\ndef·warns(\n····expected_warnings:·Snapshot[List[Warning]],\n····/,\n····include_line:·bool·=·False,\n····include_file:·bool·=·False,\n):\n····\"\"\"\n····Captures·warnings·with·`warnings.catch_warnings`·and·compares·them·against·expected·warnings.\n\n····Parameters:\n········expected_warnings:·Snapshot·containing·a·list·of·expected·warnings.\n········include_line:·If·`True`,·each·expected·warning·is·a·tuple·`(linenumber,·message)`.\n········include_file:·If·`True`,·each·expected·warning·is·a·tuple·`(filename,·message)`.\n\n····The·format·of·the·expected·warning:\n\n····-·`(filename,·linenumber,·message)`·if·both·`include_line`·and·`include_file`·are·`True`.\n····-·`(linenumber,·message)`·if·only·`include_line`·is·`True`.\n····-·`(filename,·message)`·if·only·`include_file`·is·`True`.\n····-·A·string·`message`·if·both·are·`False`.\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·warns\n········from·warnings·import·warn\n\n\n········def·test_warns():\n············with·warns(snapshot(),·include_line=True):\n················warn(\"some·problem\")\n········```\n\n····===·\"--inline-snapshot=create\"\n\n········<!--·inline-snapshot:·create·fix·outcome-passed=1·-->\n········```·python·hl_lines=\"7\"\n········from·inline_snapshot·import·snapshot\n········from·inline_snapshot.extra·import·warns\n········from·warnings·import·warn\n\n\n········def·test_warns():\n············with·warns(snapshot([(8,·\"UserWarning:·some·problem\")]),·include_line=True):\n················warn(\"some·problem\")\n········```\n····\"\"\"\n····with·warnings.catch_warnings(record=True)·as·result:\n········warnings.simplefilter(\"always\")\n········yield\n\n····def·make_warning(w):\n········message·=·f\"{w.category.__name__}:·{w.message}\"\n········if·not·include_line·and·not·include_file:\n············return·message\n········message·=·(message,)\n\n········if·include_line:\n············message·=·(w.lineno,·*message)\n········if·include_file:\n············message·=·(w.filename,·*message)\n\n········return·message\n\n····assert·[make_warning(w)·for·w·in·result]·==·expected_warnings\n</code></pre>", | 689 | ············"text":·"<p>Captures·warnings·with·<code>warnings.catch_warnings</code>·and·compares·them·against·expected·warnings.</p>·<p>Parameters:</p>·Name·Type·Description·Default·<code>expected_warnings</code>·<code>Snapshot[List[Warning]]</code>·<p>Snapshot·containing·a·list·of·expected·warnings.</p>·required·<code>include_line</code>·<code>bool</code>·<p>If·<code>True</code>,·each·expected·warning·is·a·tuple·<code>(linenumber,·message)</code>.</p>·<code>False</code>·<code>include_file</code>·<code>bool</code>·<p>If·<code>True</code>,·each·expected·warning·is·a·tuple·<code>(filename,·message)</code>.</p>·<code>False</code>·<p>The·format·of·the·expected·warning:</p>·<ul>·<li><code>(filename,·linenumber,·message)</code>·if·both·<code>include_line</code>·and·<code>include_file</code>·are·<code>True</code>.</li>·<li><code>(linenumber,·message)</code>·if·only·<code>include_line</code>·is·<code>True</code>.</li>·<li><code>(filename,·message)</code>·if·only·<code>include_file</code>·is·<code>True</code>.</li>·<li>A·string·<code>message</code>·if·both·are·<code>False</code>.</li>·</ul>·original--inline-snapshot=create·<p>·<pre><code>from·inline_snapshot·import·snapshot\nfrom·inline_snapshot.extra·import·warns\nfrom·warnings·import·warn\n\n\ndef·test_warns():\n····with·warns(snapshot(),·include_line=True):\n········warn(\"some·problem\")\n</code></pre></p>·<p>·<pre><code>from·inline_snapshot·import·snapshot\nfrom·inline_snapshot.extra·import·warns\nfrom·warnings·import·warn\n\n\ndef·test_warns():\n····with·warns(snapshot([(8,·\"UserWarning:·some·problem\")]),·include_line=True):\n········warn(\"some·problem\")\n</code></pre></p>·Source·code·in·<code>.pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/extra.py</code>·<pre><code>@contextlib.contextmanager\ndef·warns(\n····expected_warnings:·Snapshot[List[Warning]],\n····/,\n····include_line:·bool·=·False,\n····include_file:·bool·=·False,\n):\n····\"\"\"\n····Captures·warnings·with·`warnings.catch_warnings`·and·compares·them·against·expected·warnings.\n\n····Parameters:\n········expected_warnings:·Snapshot·containing·a·list·of·expected·warnings.\n········include_line:·If·`True`,·each·expected·warning·is·a·tuple·`(linenumber,·message)`.\n········include_file:·If·`True`,·each·expected·warning·is·a·tuple·`(filename,·message)`.\n\n····The·format·of·the·expected·warning:\n\n····-·`(filename,·linenumber,·message)`·if·both·`include_line`·and·`include_file`·are·`True`.\n····-·`(linenumber,·message)`·if·only·`include_line`·is·`True`.\n····-·`(filename,·message)`·if·only·`include_file`·is·`True`.\n····-·A·string·`message`·if·both·are·`False`.\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·warns\n········from·warnings·import·warn\n\n\n········def·test_warns():\n············with·warns(snapshot(),·include_line=True):\n················warn(\"some·problem\")\n········```\n\n····===·\"--inline-snapshot=create\"\n\n········<!--·inline-snapshot:·create·fix·outcome-passed=1·-->\n········```·python·hl_lines=\"7\"\n········from·inline_snapshot·import·snapshot\n········from·inline_snapshot.extra·import·warns\n········from·warnings·import·warn\n\n\n········def·test_warns():\n············with·warns(snapshot([(8,·\"UserWarning:·some·problem\")]),·include_line=True):\n················warn(\"some·problem\")\n········```\n····\"\"\"\n····with·warnings.catch_warnings(record=True)·as·result:\n········warnings.simplefilter(\"always\")\n········yield\n\n····def·make_warning(w):\n········message·=·f\"{w.category.__name__}:·{w.message}\"\n········if·not·include_line·and·not·include_file:\n············return·message\n········message·=·(message,)\n\n········if·include_line:\n············message·=·(w.lineno,·*message)\n········if·include_file:\n············message·=·(w.filename,·*message)\n\n········return·message\n\n····assert·[make_warning(w)·for·w·in·result]·==·expected_warnings\n</code></pre>", |
690 | ············"title":·"<code>warns(expected_warnings,·/,·include_line=False,·include_file=False)</code>" | 690 | ············"title":·"<code>warns(expected_warnings,·/,·include_line=False,·include_file=False)</code>" |
691 | ········}, | 691 | ········}, |
692 | ········{ | 692 | ········{ |
693 | ············"location":·"getitem_snapshot.html", | 693 | ············"location":·"getitem_snapshot.html", |
694 | ············"text":·"", | 694 | ············"text":·"", |
695 | ············"title":·"snapshot()[key]" | 695 | ············"title":·"snapshot()[key]" |
696 | ········}, | 696 | ········}, |
Offset 752, 65 lines modified | Offset 752, 65 lines modified |
752 | ········{ | 752 | ········{ |
753 | ············"location":·"outsource.html#api", | 753 | ············"location":·"outsource.html#api", |
754 | ············"text":·"", | 754 | ············"text":·"", |
755 | ············"title":·"API" | 755 | ············"title":·"API" |
756 | ········}, | 756 | ········}, |
757 | ········{ | 757 | ········{ |
758 | ············"location":·"outsource.html#inline_snapshot.outsource", | 758 | ············"location":·"outsource.html#inline_snapshot.outsource", |
759 | ············"text":·"<p>Outsource·some·data·into·an·external·file.</p>·<pre><code>>>>·png_data·=·b\"some_bytes\"··#·should·be·the·replaced·with·your·actual·data\n>>>·outsource(png_data,·suffix=\".png\")\nexternal(\"212974ed1835*.png\")\n</code></pre>·<p>Parameters:</p>·Name·Type·Description·Default·<code>data</code>·<code>Union[str,·bytes]</code>·<p>data·which·should·be·outsourced.·strings·are·encoded·with·<code>\"utf-8\"</code>.</p>·required·<code>suffix</code>·<code>Optional[str]</code>·<p>overwrite·file·suffix.·The·default·is·<code>\".bin\"</code>·if·data·is·an·instance·of·<code>bytes</code>·and·<code>\".txt\"</code>·for·<code>str</code>.</p>·<code>None</code>·<p>Returns:</p>·Type·Description·<code>external</code>·<p>The·external·data.</p>·Source·code·in·<code>.pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/_external.py</code>·<pre><code>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</code></pre>", | 759 | ············"text":·"<p>Outsource·some·data·into·an·external·file.</p>·<pre><code>>>>·png_data·=·b\"some_bytes\"··#·should·be·the·replaced·with·your·actual·data\n>>>·outsource(png_data,·suffix=\".png\")\nexternal(\"212974ed1835*.png\")\n</code></pre>·<p>Parameters:</p>·Name·Type·Description·Default·<code>data</code>·<code>Union[str,·bytes]</code>·<p>data·which·should·be·outsourced.·strings·are·encoded·with·<code>\"utf-8\"</code>.</p>·required·<code>suffix</code>·<code>Optional[str]</code>·<p>overwrite·file·suffix.·The·default·is·<code>\".bin\"</code>·if·data·is·an·instance·of·<code>bytes</code>·and·<code>\".txt\"</code>·for·<code>str</code>.</p>·<code>None</code>·<p>Returns:</p>·Type·Description·<code>external</code>·<p>The·external·data.</p>·Source·code·in·<code>.pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/_external.py</code>·<pre><code>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</code></pre>", |
760 | ············"title":·"<code>inline_snapshot.outsource(data,·*,·suffix=None)</code>" | 760 | ············"title":·"<code>inline_snapshot.outsource(data,·*,·suffix=None)</code>" |
761 | ········}, | 761 | ········}, |
762 | ········{ | 762 | ········{ |
763 | ············"location":·"outsource.html#inline_snapshot.external", | 763 | ············"location":·"outsource.html#inline_snapshot.external", |
764 | ············"text":·"Source·code·in·<code>.pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/_external.py</code>·<pre><code>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·by·default·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········To·store·data·in·a·different·location,·set·the·`storage-dir`·option·in·pyproject.toml.\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</code></pre>", | 764 | ············"text":·"Source·code·in·<code>.pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/_external.py</code>·<pre><code>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·by·default·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········To·store·data·in·a·different·location,·set·the·`storage-dir`·option·in·pyproject.toml.\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</code></pre>", |
765 | ············"title":·"<code>inline_snapshot.external</code>" | 765 | ············"title":·"<code>inline_snapshot.external</code>" |
766 | ········}, | 766 | ········}, |
767 | ········{ | 767 | ········{ |
768 | ············"location":·"outsource.html#inline_snapshot.external.__eq__", | 768 | ············"location":·"outsource.html#inline_snapshot.external.__eq__", |
769 | ············"text":·"<p>Two·external·objects·are·equal·if·they·have·the·same·hash·and·suffix.</p>·Source·code·in·<code>.pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/_external.py</code>·<pre><code>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</code></pre>", | 769 | ············"text":·"<p>Two·external·objects·are·equal·if·they·have·the·same·hash·and·suffix.</p>·Source·code·in·<code>.pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/_external.py</code>·<pre><code>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</code></pre>", |
770 | ············"title":·"<code>__eq__(other)</code>" | 770 | ············"title":·"<code>__eq__(other)</code>" |
771 | ········}, | 771 | ········}, |
772 | ········{ | 772 | ········{ |
773 | ············"location":·"outsource.html#inline_snapshot.external.__init__", | 773 | ············"location":·"outsource.html#inline_snapshot.external.__init__", |
774 | ············"text":·"<p>External·objects·are·used·as·a·representation·for·outsourced·data.·You·should·not·create·them·directly.</p>·<p>The·external·data·is·by·default·stored·inside·<code><pytest_config_dir>/.inline-snapshot/external</code>,·where·<code><pytest_config_dir></code>·is·replaced·by·the·directory·containing·the·Pytest·configuration·file,·if·any.·To·store·data·in·a·different·location,·set·the·<code>storage-dir</code>·option·in·pyproject.toml.·Data·which·is·outsourced·but·not·referenced·in·the·source·code·jet·has·a·'-new'·suffix·in·the·filename.</p>·<p>Parameters:</p>·Name·Type·Description·Default·<code>name</code>·<code>str</code>·<p>the·name·of·the·external·stored·object.</p>·required·Source·code·in·<code>.pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/_external.py</code>·<pre><code>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·by·default·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····To·store·data·in·a·different·location,·set·the·`storage-dir`·option·in·pyproject.toml.\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</code></pre>", | 774 | ············"text":·"<p>External·objects·are·used·as·a·representation·for·outsourced·data.·You·should·not·create·them·directly.</p>·<p>The·external·data·is·by·default·stored·inside·<code><pytest_config_dir>/.inline-snapshot/external</code>,·where·<code><pytest_config_dir></code>·is·replaced·by·the·directory·containing·the·Pytest·configuration·file,·if·any.·To·store·data·in·a·different·location,·set·the·<code>storage-dir</code>·option·in·pyproject.toml.·Data·which·is·outsourced·but·not·referenced·in·the·source·code·jet·has·a·'-new'·suffix·in·the·filename.</p>·<p>Parameters:</p>·Name·Type·Description·Default·<code>name</code>·<code>str</code>·<p>the·name·of·the·external·stored·object.</p>·required·Source·code·in·<code>.pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/_external.py</code>·<pre><code>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·by·default·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····To·store·data·in·a·different·location,·set·the·`storage-dir`·option·in·pyproject.toml.\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</code></pre>", |
775 | ············"title":·"<code>__init__(name)</code>" | 775 | ············"title":·"<code>__init__(name)</code>" |
776 | ········}, | 776 | ········}, |
777 | ········{ | 777 | ········{ |
778 | ············"location":·"outsource.html#inline_snapshot.external.__repr__", | 778 | ············"location":·"outsource.html#inline_snapshot.external.__repr__", |
779 | ············"text":·"<p>Returns·the·representation·of·the·external·object.</p>·<p>The·length·of·the·hash·can·be·specified·in·the·config.</p>·Source·code·in·<code>.pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/_external.py</code>·<pre><code>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</code></pre>", | 779 | ············"text":·"<p>Returns·the·representation·of·the·external·object.</p>·<p>The·length·of·the·hash·can·be·specified·in·the·config.</p>·Source·code·in·<code>.pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/_external.py</code>·<pre><code>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</code></pre>", |
780 | ············"title":·"<code>__repr__()</code>" | 780 | ············"title":·"<code>__repr__()</code>" |
781 | ········}, | 781 | ········}, |
782 | ········{ | 782 | ········{ |
783 | ············"location":·"outsource.html#pytest-options", | 783 | ············"location":·"outsource.html#pytest-options", |
784 | ············"text":·"<p>It·interacts·with·the·following·<code>--inline-snapshot</code>·flags:</p>·<ul>·<li><code>trim</code>·removes·every·snapshots·form·the·storage·which·is·not·referenced·with·<code>external(...)</code>·in·the·code.</li>·</ul>", | 784 | ············"text":·"<p>It·interacts·with·the·following·<code>--inline-snapshot</code>·flags:</p>·<ul>·<li><code>trim</code>·removes·every·snapshots·form·the·storage·which·is·not·referenced·with·<code>external(...)</code>·in·the·code.</li>·</ul>", |
785 | ············"title":·"pytest·options" | 785 | ············"title":·"pytest·options" |
786 | ········}, | 786 | ········}, |
787 | ········{ | 787 | ········{ |
788 | ············"location":·"pytest.html", | 788 | ············"location":·"pytest.html", |
789 | ············"text":·"<p>inline-snapshot·provides·one·pytest·option·with·different·flags·(create,·fix,·trim,·update,·short-report,·report,·disable).</p>·<p>Snapshot·comparisons·return·always·<code>True</code>·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:</p>·<pre><code>from·inline_snapshot·import·snapshot\n\n\ndef·test_something():\n····assert·1·==·snapshot(5)\n····assert·2·<=·snapshot(5)\n</code></pre>·<p>Note</p>·<p>Every·flag·with·the·exception·of·disable·and·short-report·disables·the·pytest·assert-rewriting.</p>", | 789 | ············"text":·"<p>inline-snapshot·provides·one·pytest·option·with·different·flags·(create,·fix,·trim,·update,·short-report,·report,·disable).</p>·<p>Snapshot·comparisons·return·always·<code>True</code>·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:</p>·<pre><code>from·inline_snapshot·import·snapshot\n\n\ndef·test_something():\n····assert·1·==·snapshot(5)\n····assert·2·<=·snapshot(5)\n</code></pre>·<p>Note</p>·<p>Every·flag·with·the·exception·of·disable·and·short-report·disables·the·pytest·assert-rewriting.</p>", |
790 | ············"title":·"pytest·integration" | 790 | ············"title":·"pytest·integration" |
791 | ········}, | 791 | ········}, |
792 | ········{ | 792 | ········{ |
793 | ············"location":·"pytest.html#-inline-snapshotcreatefixtrimupdate", | 793 | ············"location":·"pytest.html#-inline-snapshotcreatefixtrimupdate", |
794 | ············"text":·"<p>Approve·the·changes·of·the·given·category.·These·flags·can·be·combined·with·report·and·review.</p>·test_something.py<pre><code>from·inline_snapshot·import·snapshot\n\n\ndef·test_something():\n····assert·1·==·snapshot()\n····assert·2·<=·snapshot(5)\n</code></pre>·<pre><code>\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.8,·pytest-8.3.4,·pluggy-1.5.0\nrootdir:·/tmp/tmp.kFFW8kHLKp\nplugins:·hypothesis-6.122.1,·typeguard-4.4.1,·time-machine-2.16.0,·pytest_freezer-0.4.9,·inline-snapshot-0.18.1,·subtests-0.13.1,·mock-3.14.0\ncollected·1·item\n\ntest_something.py·\u001b[32m.\u001b[0m\u001b[32m·································[·...·truncated·by·diffoscope;·len:·2791,·SHA:·832957ffc5e153407fc859992e40fb842f2c78dc9ffeea69667d722fd0331ea8·...·]s\u001b[0m\u001b[32m·===============================\u001b[0m\n</code></pre>", | 794 | ············"text":·"<p>Approve·the·changes·of·the·given·category.·These·flags·can·be·combined·with·report·and·review.</p>·test_something.py<pre><code>from·inline_snapshot·import·snapshot\n\n\ndef·test_something():\n····assert·1·==·snapshot()\n····assert·2·<=·snapshot(5)\n</code></pre>·<pre><code>\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.8,·pytest-8.3.4,·pluggy-1.5.0\nrootdir:·/tmp/tmp.60FAWnReg3\nplugins:·mock-3.14.0,·subtests-0.13.1,·inline-snapshot-0.18.1,·hypothesis-6.122.1,·pytest_freezer-0.4.9,·typeguard-4.4.1,·time-machine-2.16.0\ncollected·1·item\n\ntest_something.py·\u001b[32m.\u001b[0m\u001b[32m·································[·...·truncated·by·diffoscope;·len:·2791,·SHA:·c5dccb141559cb390f435f8721dde35e66d398f3b8e70ac08bec34f97ca2d252·...·]s\u001b[0m\u001b[32m·===============================\u001b[0m\n</code></pre>", |
795 | ············"title":·"--inline-snapshot=create,fix,trim,update" | 795 | ············"title":·"--inline-snapshot=create,fix,trim,update" |
796 | ········}, | 796 | ········}, |
797 | ········{ | 797 | ········{ |
798 | ············"location":·"pytest.html#-inline-snapshotshort-report", | 798 | ············"location":·"pytest.html#-inline-snapshotshort-report", |
799 | ············"text":·"<p>give·a·short·report·over·which·changes·can·be·made·to·the·snapshots</p>·<pre><code>\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.8,·pytest-8.3.4,·pluggy-1.5.0\nrootdir:·/tmp/tmp.WxEiV9suHD\nplugins:·hypothesis-6.122.1,·typeguard-4.4.1,·time-machine-2.16.0,·pytest_freezer-0.4.9,·inline-snapshot-0.18.1,·subtests-0.13.1,·mock-3.14.0\ncollected·1·item\n\ntest_something.py·\u001b[32m.\u001b[0m\u001b[31mE\u001b[0m\u001b[31m·············[·...·truncated·by·diffoscope;·len:·932,·SHA:·9404647b77be5accf4e0a99050bc3a88762f9f7743ba48700d473b2725e19e32·...·]s\u001b[0m\u001b[31m·==========================\u001b[0m\n</code></pre>·<p>Info</p>·<p>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.</p>", | 799 | ············"text":·"<p>give·a·short·report·over·which·changes·can·be·made·to·the·snapshots</p>·<pre><code>\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.8,·pytest-8.3.4,·pluggy-1.5.0\nrootdir:·/tmp/tmp.wduPXdW8gH\nplugins:·mock-3.14.0,·subtests-0.13.1,·inline-snapshot-0.18.1,·hypothesis-6.122.1,·pytest_freezer-0.4.9,·typeguard-4.4.1,·time-machine-2.16.0\ncollected·1·item\n\ntest_something.py·\u001b[32m.\u001b[0m\u001b[31mE\u001b[0m\u001b[31m·············[·...·truncated·by·diffoscope;·len:·932,·SHA:·b1748cdc5c92ffdcce269c70ac4544d58a82d32c7c346d8d1f3824b67b31c66d·...·]s\u001b[0m\u001b[31m·==========================\u001b[0m\n</code></pre>·<p>Info</p>·<p>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.</p>", |
800 | ············"title":·"--inline-snapshot=short-report" | 800 | ············"title":·"--inline-snapshot=short-report" |
801 | ········}, | 801 | ········}, |
802 | ········{ | 802 | ········{ |
803 | ············"location":·"pytest.html#-inline-snapshotreport", | 803 | ············"location":·"pytest.html#-inline-snapshotreport", |
804 | ············"text":·"<p>Shows·a·diff·report·over·which·changes·can·be·made·to·the·snapshots</p>·<pre><code>\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.8,·pytest-8.3.4,·pluggy-1.5.0\nrootdir:·/tmp/tmp.pvYajNAczw\nplugins:·hypothesis-6.122.1,·typeguard-4.4.1,·time-machine-2.16.0,·pytest_freezer-0.4.9,·inline-snapshot-0.18.1,·subtests-0.13.1,·mock-3.14.0\ncollected·1·item\n\ntest_something.py·\u001b[32m.\u001b[0m\u001b[31mE\u001b[0m\u001b[31m·············[·...·truncated·by·diffoscope;·len:·3360,·SHA:·8a172b8cf7cb19151db5839360fc488a86838c0ef8faf99ac916d370685a1d01·...·]s\u001b[0m\u001b[31m·==========================\u001b[0m\n</code></pre>", | 804 | ············"text":·"<p>Shows·a·diff·report·over·which·changes·can·be·made·to·the·snapshots</p>·<pre><code>\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.8,·pytest-8.3.4,·pluggy-1.5.0\nrootdir:·/tmp/tmp.cu7h0QkmhQ\nplugins:·mock-3.14.0,·subtests-0.13.1,·inline-snapshot-0.18.1,·hypothesis-6.122.1,·pytest_freezer-0.4.9,·typeguard-4.4.1,·time-machine-2.16.0\ncollected·1·item\n\ntest_something.py·\u001b[32m.\u001b[0m\u001b[31mE\u001b[0m\u001b[31m·············[·...·truncated·by·diffoscope;·len:·3360,·SHA:·ded2e05e76164a296ea4acd9cf46f488b06d193d596361cf3132e8ef906fc59b·...·]s\u001b[0m\u001b[31m·==========================\u001b[0m\n</code></pre>", |
805 | ············"title":·"--inline-snapshot=report" | 805 | ············"title":·"--inline-snapshot=report" |
806 | ········}, | 806 | ········}, |
807 | ········{ | 807 | ········{ |
808 | ············"location":·"pytest.html#-inline-snapshotreview", | 808 | ············"location":·"pytest.html#-inline-snapshotreview", |
809 | ············"text":·"<p>Shows·a·diff·report·for·each·category·and·ask·if·you·want·to·apply·the·changes</p>·<pre><code>\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.8,·pytest-8.3.4,·pluggy-1.5.0\nrootdir:·/tmp/tmp.9CRz6fCaz7\nplugins:·hypothesis-6.122.1,·typeguard-4.4.1,·time-machine-2.16.0,·pytest_freezer-0.4.9,·inline-snapshot-0.18.1,·subtests-0.13.1,·mock-3.14.0\ncollected·1·item\n\ntest_something.py·\u001b[32m.\u001b[0m\u001b[32m·································[·...·truncated·by·diffoscope;·len:·2680,·SHA:·524e3162457dfcb24db3082ecb32dbb4010d8a8cfa7581ef3a73bcb2d9e8fcae·...·]s\u001b[0m\u001b[32m·===============================\u001b[0m\n</code></pre>", | 809 | ············"text":·"<p>Shows·a·diff·report·for·each·category·and·ask·if·you·want·to·apply·the·changes</p>·<pre><code>\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.8,·pytest-8.3.4,·pluggy-1.5.0\nrootdir:·/tmp/tmp.aKuOS0UTRs\nplugins:·mock-3.14.0,·subtests-0.13.1,·inline-snapshot-0.18.1,·hypothesis-6.122.1,·pytest_freezer-0.4.9,·typeguard-4.4.1,·time-machine-2.16.0\ncollected·1·item\n\ntest_something.py·\u001b[32m.\u001b[0m\u001b[32m·································[·...·truncated·by·diffoscope;·len:·2680,·SHA:·562ae034b9660bb05920d482667e36ea0c30a58d67127e9ad44acceac0d3e1f4·...·]s\u001b[0m\u001b[32m·===============================\u001b[0m\n</code></pre>", |
810 | ············"title":·"--inline-snapshot=review" | 810 | ············"title":·"--inline-snapshot=review" |
811 | ········}, | 811 | ········}, |
812 | ········{ | 812 | ········{ |
813 | ············"location":·"pytest.html#-inline-snapshotdisable", | 813 | ············"location":·"pytest.html#-inline-snapshotdisable", |
814 | ············"text":·"<p>Disables·all·the·snapshot·logic.·<code>snapshot(x)</code>·will·just·return·<code>x</code>.·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.</p>·<p>deprecation</p>·<p>This·option·was·previously·called·<code>--inline-snapshot-disable</code></p>", | 814 | ············"text":·"<p>Disables·all·the·snapshot·logic.·<code>snapshot(x)</code>·will·just·return·<code>x</code>.·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.</p>·<p>deprecation</p>·<p>This·option·was·previously·called·<code>--inline-snapshot-disable</code></p>", |
815 | ············"title":·"--inline-snapshot=disable" | 815 | ············"title":·"--inline-snapshot=disable" |
816 | ········}, | 816 | ········}, |
Offset 862, 12 lines modified | Offset 862, 12 lines modified |
862 | ········{ | 862 | ········{ |
863 | ············"location":·"types.html#inline_snapshot.Category", | 863 | ············"location":·"types.html#inline_snapshot.Category", |
864 | ············"text":·"<p>See·categories</p>", | 864 | ············"text":·"<p>See·categories</p>", |
865 | ············"title":·"<code>Category·=·Literal['update',·'fix',·'create',·'trim']</code>··<code>module-attribute</code>" | 865 | ············"title":·"<code>Category·=·Literal['update',·'fix',·'create',·'trim']</code>··<code>module-attribute</code>" |
866 | ········}, | 866 | ········}, |
867 | ········{ | 867 | ········{ |
868 | ············"location":·"types.html#inline_snapshot.Snapshot", | 868 | ············"location":·"types.html#inline_snapshot.Snapshot", |
869 | ············"text":·"<p>Can·be·used·to·annotate·function·arguments·which·accept·snapshot·values.</p>·<p>You·can·annotate·function·arguments·with·<code>Snapshot[T]</code>·to·declare·that·a·snapshot-value·can·be·passed·as·function·argument.·<code>Snapshot[T]</code>·is·a·type·alias·for·<code>T</code>,·which·allows·you·to·pass·<code>int</code>·values·instead·of·<code>int</code>·snapshots.</p>·<p>Example:</p>·<pre><code>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</code></pre>·Source·code·in·<code>.pybuild/cpython3_3.13_inline-snapshot/build/inline_snapshot/_types.py</code>·<pre><code>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</code></pre>", | 869 | ············"text":·"<p>Can·be·used·to·annotate·function·arguments·which·accept·snapshot·values.</p>·<p>You·can·annotate·function·arguments·with·<code>Snapshot[T]</code>·to·declare·that·a·snapshot-value·can·be·passed·as·function·argument.·<code>Snapshot[T]</code>·is·a·type·alias·for·<code>T</code>,·which·allows·you·to·pass·<code>int</code>·values·instead·of·<code>int</code>·snapshots.</p>·<p>Example:</p>·<pre><code>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</code></pre>·Source·code·in·<code>.pybuild/cpython3_3.12_inline-snapshot/build/inline_snapshot/_types.py</code>·<pre><code>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</code></pre>", |
870 | ············"title":·"<code>Snapshot</code>" | 870 | ············"title":·"<code>Snapshot</code>" |
871 | ········} | 871 | ········} |
872 | ····] | 872 | ····] |
873 | } | 873 | } |