--- /srv/rebuilderd/tmp/rebuilderdT5XqVD/inputs/python-inline-snapshot-doc_0.36.2-1_all.deb +++ /srv/rebuilderd/tmp/rebuilderdT5XqVD/out/python-inline-snapshot-doc_0.36.2-1_all.deb ├── file list │ @@ -1,3 +1,3 @@ │ -rw-r--r-- 0 0 0 4 2026-11-17 08:36:51.000000 debian-binary │ --rw-r--r-- 0 0 0 3840 2026-11-17 08:36:51.000000 control.tar.xz │ +-rw-r--r-- 0 0 0 3836 2026-11-17 08:36:51.000000 control.tar.xz │ -rw-r--r-- 0 0 0 2624820 2026-11-17 08:36:51.000000 data.tar.xz ├── control.tar.xz │ ├── control.tar │ │ ├── ./md5sums │ │ │ ├── ./md5sums │ │ │ │┄ Files differ ├── data.tar.xz │ ├── data.tar │ │ ├── ./usr/share/doc/python-inline-snapshot-doc/html/extra.html │ │ │ @@ -1801,15 +1801,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ - Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/extra.py │ │ │ + Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/extra.py │ │ │
│ │ │ │ │ │ │ │ │
253
│ │ │  254
│ │ │  255
│ │ │  256
│ │ │  257
│ │ │  258
│ │ │  259
│ │ │ @@ -2138,15 +2138,15 @@
│ │ │              
│ │ │ │ │ │ │ │ │
│ │ │ - Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/extra.py │ │ │ + Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/extra.py │ │ │
345
│ │ │  346
│ │ │  347
│ │ │  348
│ │ │  349
│ │ │  350
│ │ │  351
│ │ │ @@ -2302,15 +2302,15 @@
│ │ │      with prints(stdout=snapshot()):
│ │ │          print("hello")
│ │ │  

│ │ │ │ │ │ │ │ │ │ │ │
│ │ │ - Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/extra.py │ │ │ + Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/extra.py │ │ │
 96
│ │ │   97
│ │ │   98
│ │ │   99
│ │ │  100
│ │ │  101
│ │ │  102
│ │ │ @@ -2540,15 +2540,15 @@
│ │ │      with raises(snapshot()):
│ │ │          1 / 0
│ │ │  

│ │ │ │ │ │ │ │ │ │ │ │
│ │ │ - Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/extra.py │ │ │ + Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/extra.py │ │ │
40
│ │ │  41
│ │ │  42
│ │ │  43
│ │ │  44
│ │ │  45
│ │ │  46
│ │ │ @@ -2705,15 +2705,15 @@
│ │ │  
│ │ │

Tip

│ │ │

The argument of WithoutIds can also be an external WithoutIds(external()) if you want to store a large log in an external file.

│ │ │
│ │ │ │ │ │ │ │ │
│ │ │ - Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/extra.py │ │ │ + Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/extra.py │ │ │
377
│ │ │  378
│ │ │  379
│ │ │  380
│ │ │  381
│ │ │  382
│ │ │  383
│ │ │ @@ -2926,15 +2926,15 @@
│ │ │      with warns(snapshot()):
│ │ │          warn("some problem")
│ │ │  

│ │ │ │ │ │ │ │ │ │ │ │
│ │ │ - Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/extra.py │ │ │ + Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/extra.py │ │ │
175
│ │ │  176
│ │ │  177
│ │ │  178
│ │ │  179
│ │ │  180
│ │ │  181
│ │ │ ├── html2text {}
│ │ │ │ @@ -140,15 +140,15 @@
│ │ │ │                  snapshot("text can contain "),
│ │ │ │              )
│ │ │ │          }
│ │ │ │      )
│ │ │ │  Tip
│ │ │ │  You can use _@_t_r_a_n_s_f_o_r_m_a_t_i_o_n if you want to use the same transformation multiple
│ │ │ │  times.
│ │ │ │ -Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/extra.py
│ │ │ │ +Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/extra.py
│ │ │ │      @declare_unmanaged
│ │ │ │      class Transformed:
│ │ │ │          """
│ │ │ │          `Transformed` allows you to move transformations of your values from
│ │ │ │  _2_5_3 one side of the `==` to the other.
│ │ │ │  _2_5_4
│ │ │ │  _2_5_5     
│ │ │ │ @@ -280,15 +280,15 @@
│ │ │ │  NNaammee      TTyyppee                 DDeessccrriippttiioonn                            DDeeffaauulltt
│ │ │ │  func      _C_a_l_l_a_b_l_e[[_A_n_y], _A_n_y] functions which is used to transform   rreeqquuiirreedd
│ │ │ │                                 the value which is compared.
│ │ │ │  value     SnapshotArg          the result of the transformation       ...
│ │ │ │                                 this argument is unused and only
│ │ │ │  should_be _A_n_y                  reported in the repr() to show you the None
│ │ │ │                                 last transformed value.
│ │ │ │ -Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/extra.py
│ │ │ │ +Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/extra.py
│ │ │ │      def __init__(
│ │ │ │  _3_4_5     self,
│ │ │ │  _3_4_6     func: Callable[[Any], Any],
│ │ │ │  _3_4_7     value: SnapshotArg = ...,
│ │ │ │  _3_4_8     should_be: Any = None,
│ │ │ │  _3_4_9 ) -> None:
│ │ │ │  _3_5_0     """
│ │ │ │ @@ -347,15 +347,15 @@
│ │ │ │          print("some error", file=sys.stderr)
│ │ │ │  Limitation: CPython < 3.11
│ │ │ │  You have to use snapshot(...) as argument when you want to fix values on
│ │ │ │  CPython < 3.11.
│ │ │ │  def test_prints():
│ │ │ │      with prints(stdout=snapshot()):
│ │ │ │          print("hello")
│ │ │ │ -Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/extra.py
│ │ │ │ +Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/extra.py
│ │ │ │      @contextlib.contextmanager
│ │ │ │      def prints(*, stdout: SnapshotArg[str] = "", stderr: SnapshotArg[str] =
│ │ │ │  _ _9_6 ""):
│ │ │ │  _ _9_7     """Uses `contextlib.redirect_stderr/stdout` to capture the output and
│ │ │ │  _ _9_8     compare it with the snapshots. `dirty_equals.IsStr` can be used to
│ │ │ │  _ _9_9 ignore
│ │ │ │  _1_0_0     the output if needed.
│ │ │ │ @@ -460,15 +460,15 @@
│ │ │ │          1 / 0
│ │ │ │  Limitation: CPython < 3.11
│ │ │ │  You have to use snapshot(...) as argument when you want to fix values on
│ │ │ │  CPython < 3.11.
│ │ │ │  def test_raises():
│ │ │ │      with raises(snapshot()):
│ │ │ │          1 / 0
│ │ │ │ -Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/extra.py
│ │ │ │ +Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/extra.py
│ │ │ │     @contextlib.contextmanager
│ │ │ │     def raises(exception: SnapshotArg[str] = ..., /):
│ │ │ │  _4_0     """Check that an exception is raised.
│ │ │ │  _4_1
│ │ │ │  _4_2     Parameters:
│ │ │ │  _4_3         exception: Snapshot that is compared with the formatted exception if
│ │ │ │  _4_4 an exception occurs:
│ │ │ │ @@ -555,15 +555,15 @@
│ │ │ │                  )
│ │ │ │              ]
│ │ │ │          }
│ │ │ │      )
│ │ │ │  Tip
│ │ │ │  The argument of WithoutIds can also be an external WithoutIds(external()) if
│ │ │ │  you want to store a large log in an external file.
│ │ │ │ -Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/extra.py
│ │ │ │ +Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/extra.py
│ │ │ │      def transformation(func):
│ │ │ │          """
│ │ │ │  _3_7_7
│ │ │ │  _3_7_8     `@transformation` can be used to bind a function to [Transformed]
│ │ │ │  _3_7_9 [inline_snapshot.extra.Transformed],
│ │ │ │  _3_8_0     which simplifies your code if you want to use the same transformation
│ │ │ │  _3_8_1 multiple times.
│ │ │ │ @@ -650,15 +650,15 @@
│ │ │ │          warn("some problem")
│ │ │ │  Limitation: CPython < 3.11
│ │ │ │  You have to use snapshot(...) as argument when you want to fix values on
│ │ │ │  CPython < 3.11.
│ │ │ │  def test_warns():
│ │ │ │      with warns(snapshot()):
│ │ │ │          warn("some problem")
│ │ │ │ -Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/extra.py
│ │ │ │ +Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/extra.py
│ │ │ │      @contextlib.contextmanager
│ │ │ │      def warns(
│ │ │ │          expected_warnings: SnapshotArg[List[Warning]] = ...,
│ │ │ │          /,
│ │ │ │  _1_7_5     include_line: bool = False,
│ │ │ │  _1_7_6     include_file: bool = False,
│ │ │ │  _1_7_7 ):
│ │ ├── ./usr/share/doc/python-inline-snapshot-doc/html/search/search_index.json
│ │ │ ├── Pretty-printed
│ │ │ │ @@ -1487,40 +1487,40 @@
│ │ │ │          {
│ │ │ │              "location": "extra.html#inline_snapshot.extra",
│ │ │ │              "text": "

The following functions are built on top of inline-snapshot and could also be implemented in an extra library. The source is added to the documentation, which allows you to look at how they are implemented and implement similar functions if you need them.

They are part of inline-snapshot because they are generally useful and do not depend on other libraries.

", │ │ │ │ "title": "inline_snapshot.extra" │ │ │ │ }, │ │ │ │ { │ │ │ │ "location": "extra.html#inline_snapshot.extra.Transformed", │ │ │ │ - "text": "

Transformed allows you to move transformations of your values from one side of the == to the other.

from inline_snapshot import snapshot\nfrom inline_snapshot.extra import Transformed\n\n\ndef test_transform():\n    numbers = [1, 8, 3, 7, 5]\n    assert sorted(numbers) == snapshot()\n    assert numbers == Transformed(sorted, snapshot())\n

Both assertions create the same snapshots.

from inline_snapshot import snapshot\nfrom inline_snapshot.extra import Transformed\n\n\ndef test_transform():\n    numbers = [1, 8, 3, 7, 5]\n    assert sorted(numbers) == snapshot([1, 3, 5, 7, 8])\n    assert numbers == Transformed(sorted, snapshot([1, 3, 5, 7, 8]))\n

Transformed is more flexible to use because you can also use it deep inside data structures. The following example shows how Transformed is used inside a dictionary.

from random import shuffle\nfrom inline_snapshot import snapshot\nfrom inline_snapshot.extra import Transformed\n\n\ndef request():\n    data = [1, 8, 18748, 493]\n    shuffle(data)\n    return {\"name\": \"example\", \"data\": data}\n\n\ndef test_request():\n    assert request() == snapshot(\n        {\n            \"name\": \"example\",\n            \"data\": Transformed(sorted, snapshot([1, 8, 493, 18748])),\n        }\n    )\n

Or to normalize strings.

import re\nfrom inline_snapshot import snapshot\nfrom inline_snapshot.extra import Transformed\n\n\nclass Thing:\n    def __repr__(self):\n        return \"<Thing with some random id 152897513>\"\n\n\ndef without_ids(text):\n    return re.sub(r\"<([^0-9]*)[^>]+>\", lambda m: f\"<{m[1]} ...>\", text)\n\n\ndef test_text_with_objects():\n    text = f\"text can contain {Thing()}\"\n\n    assert {\"logs\": text} == snapshot(\n        {\n            \"logs\": Transformed(\n                without_ids,\n                snapshot(\"text can contain <Thing with some random id  ...>\"),\n            )\n        }\n    )\n

Tip

You can use @transformation if you want to use the same transformation multiple times.

Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/extra.py
@declare_unmanaged\nclass Transformed:\n    \"\"\"\n    `Transformed` allows you to move transformations of your values from one side of the `==` to the other.\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 Transformed\n\n\n    def test_transform():\n        numbers = [1, 8, 3, 7, 5]\n        assert sorted(numbers) == snapshot()\n        assert numbers == Transformed(sorted, snapshot())\n    ```\n\n    Both assertions create the same snapshots.\n\n    <!-- inline-snapshot: create outcome-passed=1 outcome-errors=1 -->\n    ``` python hl_lines=\"7 8\"\n    from inline_snapshot import snapshot\n    from inline_snapshot.extra import Transformed\n\n\n    def test_transform():\n        numbers = [1, 8, 3, 7, 5]\n        assert sorted(numbers) == snapshot([1, 3, 5, 7, 8])\n        assert numbers == Transformed(sorted, snapshot([1, 3, 5, 7, 8]))\n    ```\n\n    `Transformed` is more flexible to use because you can also use it deep inside data structures.\n    The following example shows how `Transformed` is used inside a dictionary.\n\n    <!-- inline-snapshot: create fix first_block outcome-passed=1 -->\n    ``` python\n    from random import shuffle\n    from inline_snapshot import snapshot\n    from inline_snapshot.extra import Transformed\n\n\n    def request():\n        data = [1, 8, 18748, 493]\n        shuffle(data)\n        return {\"name\": \"example\", \"data\": data}\n\n\n    def test_request():\n        assert request() == snapshot(\n            {\n                \"name\": \"example\",\n                \"data\": Transformed(sorted, snapshot([1, 8, 493, 18748])),\n            }\n        )\n    ```\n\n    Or to normalize strings.\n\n    <!-- inline-snapshot: create fix first_block outcome-passed=1 -->\n    ``` python\n    import re\n    from inline_snapshot import snapshot\n    from inline_snapshot.extra import Transformed\n\n\n    class Thing:\n        def __repr__(self):\n            return \"<Thing with some random id 152897513>\"\n\n\n    def without_ids(text):\n        return re.sub(r\"<([^0-9]*)[^>]+>\", lambda m: f\"<{m[1]} ...>\", text)\n\n\n    def test_text_with_objects():\n        text = f\"text can contain {Thing()}\"\n\n        assert {\"logs\": text} == snapshot(\n            {\n                \"logs\": Transformed(\n                    without_ids,\n                    snapshot(\"text can contain <Thing with some random id  ...>\"),\n                )\n            }\n        )\n    ```\n\n\n    !!! Tip\n        You can use [@transformation][inline_snapshot.extra.transformation] if you want to use the same transformation multiple times.\n    \"\"\"\n\n    def __init__(\n        self,\n        func: Callable[[Any], Any],\n        value: SnapshotArg = ...,\n        should_be: Any = None,\n    ) -> None:\n        \"\"\"\n        Arguments:\n            func: functions which is used to transform the value which is compared.\n            value: the result of the transformation\n            should_be: this argument is unused and only reported in the `repr()` to show you the last transformed value.\n        \"\"\"\n        self._func = func\n        self._value = snapshot_arg(value)\n        self._last_transformed_value = None\n\n    def __eq__(self, other) -> bool:\n        self._last_transformed_value = self._func(other)\n        return self._last_transformed_value == self._value\n\n    def __repr__(self):\n        try:\n            code = code_repr(self._func)\n        except Exception as e:  # pragma: no cover\n            code = f\"<exception {e}>\"\n\n        if self._last_transformed_value == self._value:\n            return f\"Transformed({code}, {self._value})\"\n        else:\n            return f\"Transformed({code}, {self._value}, should_be={self._last_transformed_value!r})\"\n
", │ │ │ │ + "text": "

Transformed allows you to move transformations of your values from one side of the == to the other.

from inline_snapshot import snapshot\nfrom inline_snapshot.extra import Transformed\n\n\ndef test_transform():\n    numbers = [1, 8, 3, 7, 5]\n    assert sorted(numbers) == snapshot()\n    assert numbers == Transformed(sorted, snapshot())\n

Both assertions create the same snapshots.

from inline_snapshot import snapshot\nfrom inline_snapshot.extra import Transformed\n\n\ndef test_transform():\n    numbers = [1, 8, 3, 7, 5]\n    assert sorted(numbers) == snapshot([1, 3, 5, 7, 8])\n    assert numbers == Transformed(sorted, snapshot([1, 3, 5, 7, 8]))\n

Transformed is more flexible to use because you can also use it deep inside data structures. The following example shows how Transformed is used inside a dictionary.

from random import shuffle\nfrom inline_snapshot import snapshot\nfrom inline_snapshot.extra import Transformed\n\n\ndef request():\n    data = [1, 8, 18748, 493]\n    shuffle(data)\n    return {\"name\": \"example\", \"data\": data}\n\n\ndef test_request():\n    assert request() == snapshot(\n        {\n            \"name\": \"example\",\n            \"data\": Transformed(sorted, snapshot([1, 8, 493, 18748])),\n        }\n    )\n

Or to normalize strings.

import re\nfrom inline_snapshot import snapshot\nfrom inline_snapshot.extra import Transformed\n\n\nclass Thing:\n    def __repr__(self):\n        return \"<Thing with some random id 152897513>\"\n\n\ndef without_ids(text):\n    return re.sub(r\"<([^0-9]*)[^>]+>\", lambda m: f\"<{m[1]} ...>\", text)\n\n\ndef test_text_with_objects():\n    text = f\"text can contain {Thing()}\"\n\n    assert {\"logs\": text} == snapshot(\n        {\n            \"logs\": Transformed(\n                without_ids,\n                snapshot(\"text can contain <Thing with some random id  ...>\"),\n            )\n        }\n    )\n

Tip

You can use @transformation if you want to use the same transformation multiple times.

Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/extra.py
@declare_unmanaged\nclass Transformed:\n    \"\"\"\n    `Transformed` allows you to move transformations of your values from one side of the `==` to the other.\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 Transformed\n\n\n    def test_transform():\n        numbers = [1, 8, 3, 7, 5]\n        assert sorted(numbers) == snapshot()\n        assert numbers == Transformed(sorted, snapshot())\n    ```\n\n    Both assertions create the same snapshots.\n\n    <!-- inline-snapshot: create outcome-passed=1 outcome-errors=1 -->\n    ``` python hl_lines=\"7 8\"\n    from inline_snapshot import snapshot\n    from inline_snapshot.extra import Transformed\n\n\n    def test_transform():\n        numbers = [1, 8, 3, 7, 5]\n        assert sorted(numbers) == snapshot([1, 3, 5, 7, 8])\n        assert numbers == Transformed(sorted, snapshot([1, 3, 5, 7, 8]))\n    ```\n\n    `Transformed` is more flexible to use because you can also use it deep inside data structures.\n    The following example shows how `Transformed` is used inside a dictionary.\n\n    <!-- inline-snapshot: create fix first_block outcome-passed=1 -->\n    ``` python\n    from random import shuffle\n    from inline_snapshot import snapshot\n    from inline_snapshot.extra import Transformed\n\n\n    def request():\n        data = [1, 8, 18748, 493]\n        shuffle(data)\n        return {\"name\": \"example\", \"data\": data}\n\n\n    def test_request():\n        assert request() == snapshot(\n            {\n                \"name\": \"example\",\n                \"data\": Transformed(sorted, snapshot([1, 8, 493, 18748])),\n            }\n        )\n    ```\n\n    Or to normalize strings.\n\n    <!-- inline-snapshot: create fix first_block outcome-passed=1 -->\n    ``` python\n    import re\n    from inline_snapshot import snapshot\n    from inline_snapshot.extra import Transformed\n\n\n    class Thing:\n        def __repr__(self):\n            return \"<Thing with some random id 152897513>\"\n\n\n    def without_ids(text):\n        return re.sub(r\"<([^0-9]*)[^>]+>\", lambda m: f\"<{m[1]} ...>\", text)\n\n\n    def test_text_with_objects():\n        text = f\"text can contain {Thing()}\"\n\n        assert {\"logs\": text} == snapshot(\n            {\n                \"logs\": Transformed(\n                    without_ids,\n                    snapshot(\"text can contain <Thing with some random id  ...>\"),\n                )\n            }\n        )\n    ```\n\n\n    !!! Tip\n        You can use [@transformation][inline_snapshot.extra.transformation] if you want to use the same transformation multiple times.\n    \"\"\"\n\n    def __init__(\n        self,\n        func: Callable[[Any], Any],\n        value: SnapshotArg = ...,\n        should_be: Any = None,\n    ) -> None:\n        \"\"\"\n        Arguments:\n            func: functions which is used to transform the value which is compared.\n            value: the result of the transformation\n            should_be: this argument is unused and only reported in the `repr()` to show you the last transformed value.\n        \"\"\"\n        self._func = func\n        self._value = snapshot_arg(value)\n        self._last_transformed_value = None\n\n    def __eq__(self, other) -> bool:\n        self._last_transformed_value = self._func(other)\n        return self._last_transformed_value == self._value\n\n    def __repr__(self):\n        try:\n            code = code_repr(self._func)\n        except Exception as e:  # pragma: no cover\n            code = f\"<exception {e}>\"\n\n        if self._last_transformed_value == self._value:\n            return f\"Transformed({code}, {self._value})\"\n        else:\n            return f\"Transformed({code}, {self._value}, should_be={self._last_transformed_value!r})\"\n
", │ │ │ │ "title": "Transformed" │ │ │ │ }, │ │ │ │ { │ │ │ │ "location": "extra.html#inline_snapshot.extra.Transformed.__init__", │ │ │ │ - "text": "

Parameters:

Name Type Description Default func Callable[[Any], Any]

functions which is used to transform the value which is compared.

required value SnapshotArg

the result of the transformation

... should_be Any

this argument is unused and only reported in the repr() to show you the last transformed value.

None Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/extra.py
def __init__(\n    self,\n    func: Callable[[Any], Any],\n    value: SnapshotArg = ...,\n    should_be: Any = None,\n) -> None:\n    \"\"\"\n    Arguments:\n        func: functions which is used to transform the value which is compared.\n        value: the result of the transformation\n        should_be: this argument is unused and only reported in the `repr()` to show you the last transformed value.\n    \"\"\"\n    self._func = func\n    self._value = snapshot_arg(value)\n    self._last_transformed_value = None\n
", │ │ │ │ + "text": "

Parameters:

Name Type Description Default func Callable[[Any], Any]

functions which is used to transform the value which is compared.

required value SnapshotArg

the result of the transformation

... should_be Any

this argument is unused and only reported in the repr() to show you the last transformed value.

None Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/extra.py
def __init__(\n    self,\n    func: Callable[[Any], Any],\n    value: SnapshotArg = ...,\n    should_be: Any = None,\n) -> None:\n    \"\"\"\n    Arguments:\n        func: functions which is used to transform the value which is compared.\n        value: the result of the transformation\n        should_be: this argument is unused and only reported in the `repr()` to show you the last transformed value.\n    \"\"\"\n    self._func = func\n    self._value = snapshot_arg(value)\n    self._last_transformed_value = None\n
", │ │ │ │ "title": "__init__(func, value=..., should_be=None)" │ │ │ │ }, │ │ │ │ { │ │ │ │ "location": "extra.html#inline_snapshot.extra.prints", │ │ │ │ - "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 SnapshotArg[str]

Snapshot that is compared to the recorded output.

'' stderr SnapshotArg[str]

Snapshot that is compared to the recorded error output.

'' original--inline-snapshot=fixignore stdout

import sys\nfrom inline_snapshot import snapshot\nfrom inline_snapshot.extra import prints\n\n\ndef test_prints():\n    with prints():\n        print(\"hello world\")\n        print(\"some error\", file=sys.stderr)\n

import sys\nfrom inline_snapshot import snapshot\nfrom inline_snapshot.extra import prints\n\n\ndef test_prints():\n    with prints(stderr=\"some error\\n\", stdout=\"hello world\\n\"):\n        print(\"hello world\")\n        print(\"some error\", file=sys.stderr)\n

import sys\nfrom dirty_equals import IsStr\nfrom inline_snapshot import snapshot\nfrom inline_snapshot.extra import prints\n\n\ndef test_prints():\n    with prints(\n        stdout=IsStr(),\n        stderr=\"some error\\n\",\n    ):\n        print(\"hello world\")\n        print(\"some error\", file=sys.stderr)\n

Limitation: CPython < 3.11

You have to use snapshot(...) as argument when you want to fix values on CPython < 3.11.

def test_prints():\n    with prints(stdout=snapshot()):\n        print(\"hello\")\n

Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/extra.py
@contextlib.contextmanager\ndef prints(*, stdout: SnapshotArg[str] = \"\", stderr: SnapshotArg[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 that is compared to the recorded output.\n        stderr: Snapshot that is compared to the recorded error output.\n\n    === \"original\"\n\n        <!-- inline-snapshot: first_block outcome-failed=1 outcome-errors=1 -->\n        ``` python\n        import sys\n        from inline_snapshot import snapshot\n        from inline_snapshot.extra import prints\n\n\n        def test_prints():\n            with prints():\n                print(\"hello world\")\n                print(\"some error\", file=sys.stderr)\n        ```\n\n    === \"--inline-snapshot=fix\"\n\n        <!-- inline-snapshot: fix outcome-passed=1 outcome-errors=1 -->\n        ``` python hl_lines=\"7\"\n        import sys\n        from inline_snapshot import snapshot\n        from inline_snapshot.extra import prints\n\n\n        def test_prints():\n            with prints(stderr=\"some error\\\\n\", stdout=\"hello world\\\\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=\"2 8 9 10 11\"\n        import sys\n        from dirty_equals import IsStr\n        from inline_snapshot import snapshot\n        from inline_snapshot.extra import prints\n\n\n        def test_prints():\n            with prints(\n                stdout=IsStr(),\n                stderr=\"some error\\\\n\",\n            ):\n                print(\"hello world\")\n                print(\"some error\", file=sys.stderr)\n        ```\n\n    ??? info \"Limitation: CPython < 3.11\"\n        You have to use `snapshot(...)` as argument when you want to fix values on CPython < 3.11.\n        ``` python\n        def test_prints():\n            with prints(stdout=snapshot()):\n                print(\"hello\")\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() == snapshot_arg(stderr)\n    assert stdout_io.getvalue() == snapshot_arg(stdout)\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 SnapshotArg[str]

Snapshot that is compared to the recorded output.

'' stderr SnapshotArg[str]

Snapshot that is compared to the recorded error output.

'' original--inline-snapshot=fixignore stdout

import sys\nfrom inline_snapshot import snapshot\nfrom inline_snapshot.extra import prints\n\n\ndef test_prints():\n    with prints():\n        print(\"hello world\")\n        print(\"some error\", file=sys.stderr)\n

import sys\nfrom inline_snapshot import snapshot\nfrom inline_snapshot.extra import prints\n\n\ndef test_prints():\n    with prints(stderr=\"some error\\n\", stdout=\"hello world\\n\"):\n        print(\"hello world\")\n        print(\"some error\", file=sys.stderr)\n

import sys\nfrom dirty_equals import IsStr\nfrom inline_snapshot import snapshot\nfrom inline_snapshot.extra import prints\n\n\ndef test_prints():\n    with prints(\n        stdout=IsStr(),\n        stderr=\"some error\\n\",\n    ):\n        print(\"hello world\")\n        print(\"some error\", file=sys.stderr)\n

Limitation: CPython < 3.11

You have to use snapshot(...) as argument when you want to fix values on CPython < 3.11.

def test_prints():\n    with prints(stdout=snapshot()):\n        print(\"hello\")\n

Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/extra.py
@contextlib.contextmanager\ndef prints(*, stdout: SnapshotArg[str] = \"\", stderr: SnapshotArg[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 that is compared to the recorded output.\n        stderr: Snapshot that is compared to the recorded error output.\n\n    === \"original\"\n\n        <!-- inline-snapshot: first_block outcome-failed=1 outcome-errors=1 -->\n        ``` python\n        import sys\n        from inline_snapshot import snapshot\n        from inline_snapshot.extra import prints\n\n\n        def test_prints():\n            with prints():\n                print(\"hello world\")\n                print(\"some error\", file=sys.stderr)\n        ```\n\n    === \"--inline-snapshot=fix\"\n\n        <!-- inline-snapshot: fix outcome-passed=1 outcome-errors=1 -->\n        ``` python hl_lines=\"7\"\n        import sys\n        from inline_snapshot import snapshot\n        from inline_snapshot.extra import prints\n\n\n        def test_prints():\n            with prints(stderr=\"some error\\\\n\", stdout=\"hello world\\\\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=\"2 8 9 10 11\"\n        import sys\n        from dirty_equals import IsStr\n        from inline_snapshot import snapshot\n        from inline_snapshot.extra import prints\n\n\n        def test_prints():\n            with prints(\n                stdout=IsStr(),\n                stderr=\"some error\\\\n\",\n            ):\n                print(\"hello world\")\n                print(\"some error\", file=sys.stderr)\n        ```\n\n    ??? info \"Limitation: CPython < 3.11\"\n        You have to use `snapshot(...)` as argument when you want to fix values on CPython < 3.11.\n        ``` python\n        def test_prints():\n            with prints(stdout=snapshot()):\n                print(\"hello\")\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() == snapshot_arg(stderr)\n    assert stdout_io.getvalue() == snapshot_arg(stdout)\n
", │ │ │ │ "title": "prints(*, stdout='', stderr='')" │ │ │ │ }, │ │ │ │ { │ │ │ │ "location": "extra.html#inline_snapshot.extra.raises", │ │ │ │ - "text": "

Check that an exception is raised.

Parameters:

Name Type Description Default exception SnapshotArg[str]

Snapshot that is compared with the formatted exception if an exception occurs: type(exception).__name__ when the message is empty or whitespace only, f\"{type}:\\n{message}\" when the message contains a newline, and f\"{type}: {message}\" otherwise; or \"<no exception>\" if no exception is raised.

... original--inline-snapshot=create

from inline_snapshot import snapshot\nfrom inline_snapshot.extra import raises\n\n\ndef test_raises():\n    with raises():\n        1 / 0\n

from inline_snapshot import snapshot\nfrom inline_snapshot.extra import raises\n\n\ndef test_raises():\n    with raises(\"ZeroDivisionError: division by zero\"):\n        1 / 0\n

Limitation: CPython < 3.11

You have to use snapshot(...) as argument when you want to fix values on CPython < 3.11.

def test_raises():\n    with raises(snapshot()):\n        1 / 0\n

Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/extra.py
@contextlib.contextmanager\ndef raises(exception: SnapshotArg[str] = ..., /):\n    \"\"\"Check that an exception is raised.\n\n    Parameters:\n        exception: Snapshot that is compared with the formatted exception if an exception occurs:\n            `#!python type(exception).__name__` when the message is empty or whitespace only,\n            `#!python f\"{type}:\\\\n{message}\"` when the message contains a newline, and\n            `#!python f\"{type}: {message}\"` otherwise;\n            or `#!python \"<no exception>\"` if no exception is raised.\n\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():\n                1 / 0\n        ```\n\n    === \"--inline-snapshot=create\"\n\n        <!-- inline-snapshot: create outcome-passed=1 outcome-errors=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(\"ZeroDivisionError: division by zero\"):\n                1 / 0\n        ```\n\n    ??? info \"Limitation: CPython < 3.11\"\n        You have to use `snapshot(...)` as argument when you want to fix values on CPython < 3.11.\n        ``` python\n        def test_raises():\n            with raises(snapshot()):\n                1 / 0\n        ```\n    \"\"\"\n    exception = snapshot_arg(exception)\n\n    try:\n        yield\n    except BaseException as ex:\n        assert _format_exception(ex) == exception\n    else:\n        assert \"<no exception>\" == exception\n
", │ │ │ │ + "text": "

Check that an exception is raised.

Parameters:

Name Type Description Default exception SnapshotArg[str]

Snapshot that is compared with the formatted exception if an exception occurs: type(exception).__name__ when the message is empty or whitespace only, f\"{type}:\\n{message}\" when the message contains a newline, and f\"{type}: {message}\" otherwise; or \"<no exception>\" if no exception is raised.

... original--inline-snapshot=create

from inline_snapshot import snapshot\nfrom inline_snapshot.extra import raises\n\n\ndef test_raises():\n    with raises():\n        1 / 0\n

from inline_snapshot import snapshot\nfrom inline_snapshot.extra import raises\n\n\ndef test_raises():\n    with raises(\"ZeroDivisionError: division by zero\"):\n        1 / 0\n

Limitation: CPython < 3.11

You have to use snapshot(...) as argument when you want to fix values on CPython < 3.11.

def test_raises():\n    with raises(snapshot()):\n        1 / 0\n

Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/extra.py
@contextlib.contextmanager\ndef raises(exception: SnapshotArg[str] = ..., /):\n    \"\"\"Check that an exception is raised.\n\n    Parameters:\n        exception: Snapshot that is compared with the formatted exception if an exception occurs:\n            `#!python type(exception).__name__` when the message is empty or whitespace only,\n            `#!python f\"{type}:\\\\n{message}\"` when the message contains a newline, and\n            `#!python f\"{type}: {message}\"` otherwise;\n            or `#!python \"<no exception>\"` if no exception is raised.\n\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():\n                1 / 0\n        ```\n\n    === \"--inline-snapshot=create\"\n\n        <!-- inline-snapshot: create outcome-passed=1 outcome-errors=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(\"ZeroDivisionError: division by zero\"):\n                1 / 0\n        ```\n\n    ??? info \"Limitation: CPython < 3.11\"\n        You have to use `snapshot(...)` as argument when you want to fix values on CPython < 3.11.\n        ``` python\n        def test_raises():\n            with raises(snapshot()):\n                1 / 0\n        ```\n    \"\"\"\n    exception = snapshot_arg(exception)\n\n    try:\n        yield\n    except BaseException as ex:\n        assert _format_exception(ex) == exception\n    else:\n        assert \"<no exception>\" == exception\n
", │ │ │ │ "title": "raises(exception=...)" │ │ │ │ }, │ │ │ │ { │ │ │ │ "location": "extra.html#inline_snapshot.extra.transformation", │ │ │ │ - "text": "

@transformation can be used to bind a function to Transformed, which simplifies your code if you want to use the same transformation multiple times.

import re\nfrom inline_snapshot import snapshot\nfrom inline_snapshot.extra import transformation\n\n\nclass Thing:\n    def __repr__(self):\n        return \"<Thing with some random id 152897513>\"\n\n\n@transformation\ndef WithoutIds(text):\n    return re.sub(r\"<([^0-9]*)[^>]+>\", lambda m: f\"<{m[1]} ...>\", text)\n\n\ndef test_text_with_objects():\n    text = f\"text can contain {Thing()}\"\n\n    assert {\"logs\": [text]} == snapshot(\n        {\n            \"logs\": [\n                WithoutIds(\n                    snapshot(\n                        \"text can contain <Thing with some random id  ...>\"\n                    )\n                )\n            ]\n        }\n    )\n

Tip

The argument of WithoutIds can also be an external WithoutIds(external()) if you want to store a large log in an external file.

Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/extra.py
def transformation(func):\n    \"\"\"\n\n    `@transformation` can be used to bind a function to [Transformed][inline_snapshot.extra.Transformed],\n    which simplifies your code if you want to use the same transformation multiple times.\n\n    <!-- inline-snapshot: create first_block outcome-passed=1 -->\n    ``` python\n    import re\n    from inline_snapshot import snapshot\n    from inline_snapshot.extra import transformation\n\n\n    class Thing:\n        def __repr__(self):\n            return \"<Thing with some random id 152897513>\"\n\n\n    @transformation\n    def WithoutIds(text):\n        return re.sub(r\"<([^0-9]*)[^>]+>\", lambda m: f\"<{m[1]} ...>\", text)\n\n\n    def test_text_with_objects():\n        text = f\"text can contain {Thing()}\"\n\n        assert {\"logs\": [text]} == snapshot(\n            {\n                \"logs\": [\n                    WithoutIds(\n                        snapshot(\n                            \"text can contain <Thing with some random id  ...>\"\n                        )\n                    )\n                ]\n            }\n        )\n    ```\n\n    !!! Tip\n        The argument of `WithoutIds` can also be an external `WithoutIds(external())` if you want to store a large log in an external file.\n    \"\"\"\n\n    def f(value):\n        return Transformed(func, snapshot_arg(value))\n\n    return f\n
", │ │ │ │ + "text": "

@transformation can be used to bind a function to Transformed, which simplifies your code if you want to use the same transformation multiple times.

import re\nfrom inline_snapshot import snapshot\nfrom inline_snapshot.extra import transformation\n\n\nclass Thing:\n    def __repr__(self):\n        return \"<Thing with some random id 152897513>\"\n\n\n@transformation\ndef WithoutIds(text):\n    return re.sub(r\"<([^0-9]*)[^>]+>\", lambda m: f\"<{m[1]} ...>\", text)\n\n\ndef test_text_with_objects():\n    text = f\"text can contain {Thing()}\"\n\n    assert {\"logs\": [text]} == snapshot(\n        {\n            \"logs\": [\n                WithoutIds(\n                    snapshot(\n                        \"text can contain <Thing with some random id  ...>\"\n                    )\n                )\n            ]\n        }\n    )\n

Tip

The argument of WithoutIds can also be an external WithoutIds(external()) if you want to store a large log in an external file.

Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/extra.py
def transformation(func):\n    \"\"\"\n\n    `@transformation` can be used to bind a function to [Transformed][inline_snapshot.extra.Transformed],\n    which simplifies your code if you want to use the same transformation multiple times.\n\n    <!-- inline-snapshot: create first_block outcome-passed=1 -->\n    ``` python\n    import re\n    from inline_snapshot import snapshot\n    from inline_snapshot.extra import transformation\n\n\n    class Thing:\n        def __repr__(self):\n            return \"<Thing with some random id 152897513>\"\n\n\n    @transformation\n    def WithoutIds(text):\n        return re.sub(r\"<([^0-9]*)[^>]+>\", lambda m: f\"<{m[1]} ...>\", text)\n\n\n    def test_text_with_objects():\n        text = f\"text can contain {Thing()}\"\n\n        assert {\"logs\": [text]} == snapshot(\n            {\n                \"logs\": [\n                    WithoutIds(\n                        snapshot(\n                            \"text can contain <Thing with some random id  ...>\"\n                        )\n                    )\n                ]\n            }\n        )\n    ```\n\n    !!! Tip\n        The argument of `WithoutIds` can also be an external `WithoutIds(external())` if you want to store a large log in an external file.\n    \"\"\"\n\n    def f(value):\n        return Transformed(func, snapshot_arg(value))\n\n    return f\n
", │ │ │ │ "title": "transformation(func)" │ │ │ │ }, │ │ │ │ { │ │ │ │ "location": "extra.html#inline_snapshot.extra.warns", │ │ │ │ - "text": "

Captures warnings with warnings.catch_warnings and compares them against expected warnings.

Parameters:

Name Type Description Default expected_warnings SnapshotArg[List[Warning]]

Snapshot containing a list of expected warnings.

... include_line bool

If True, each expected warning is a tuple (line_number, message).

False include_file bool

If True, each expected warning is a tuple (filename, message).

False

The format of the expected warning:

  • (filename, line_number, message) if both include_line and include_file are True.
  • (line_number, message) if only include_line is True.
  • (filename, message) if only include_file is True.
  • A string message if both are False.
original--inline-snapshot=create

from warnings import warn\nfrom inline_snapshot import snapshot\nfrom inline_snapshot.extra import warns\n\n\ndef test_warns():\n    with warns(include_line=True):\n        warn(\"some problem\")\n

from warnings import warn\nfrom inline_snapshot import snapshot\nfrom inline_snapshot.extra import warns\n\n\ndef test_warns():\n    with warns([(8, \"UserWarning: some problem\")], include_line=True):\n        warn(\"some problem\")\n

Limitation: CPython < 3.11

You have to use snapshot(...) as argument when you want to fix values on CPython < 3.11.

def test_warns():\n    with warns(snapshot()):\n        warn(\"some problem\")\n

Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/extra.py
@contextlib.contextmanager\ndef warns(\n    expected_warnings: SnapshotArg[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 `(line_number, 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, line_number, message)` if both `include_line` and `include_file` are `True`.\n    - `(line_number, 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 warnings import warn\n        from inline_snapshot import snapshot\n        from inline_snapshot.extra import warns\n\n\n        def test_warns():\n            with warns(include_line=True):\n                warn(\"some problem\")\n        ```\n\n    === \"--inline-snapshot=create\"\n\n        <!-- inline-snapshot: create fix outcome-passed=1 outcome-errors=1 -->\n        ``` python hl_lines=\"7\"\n        from warnings import warn\n        from inline_snapshot import snapshot\n        from inline_snapshot.extra import warns\n\n\n        def test_warns():\n            with warns([(8, \"UserWarning: some problem\")], include_line=True):\n                warn(\"some problem\")\n        ```\n\n    ??? info \"Limitation: CPython < 3.11\"\n        You have to use `snapshot(...)` as argument when you want to fix values on CPython < 3.11.\n        ``` python\n        def test_warns():\n            with warns(snapshot()):\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] == snapshot_arg(expected_warnings)\n
", │ │ │ │ + "text": "

Captures warnings with warnings.catch_warnings and compares them against expected warnings.

Parameters:

Name Type Description Default expected_warnings SnapshotArg[List[Warning]]

Snapshot containing a list of expected warnings.

... include_line bool

If True, each expected warning is a tuple (line_number, message).

False include_file bool

If True, each expected warning is a tuple (filename, message).

False

The format of the expected warning:

  • (filename, line_number, message) if both include_line and include_file are True.
  • (line_number, message) if only include_line is True.
  • (filename, message) if only include_file is True.
  • A string message if both are False.
original--inline-snapshot=create

from warnings import warn\nfrom inline_snapshot import snapshot\nfrom inline_snapshot.extra import warns\n\n\ndef test_warns():\n    with warns(include_line=True):\n        warn(\"some problem\")\n

from warnings import warn\nfrom inline_snapshot import snapshot\nfrom inline_snapshot.extra import warns\n\n\ndef test_warns():\n    with warns([(8, \"UserWarning: some problem\")], include_line=True):\n        warn(\"some problem\")\n

Limitation: CPython < 3.11

You have to use snapshot(...) as argument when you want to fix values on CPython < 3.11.

def test_warns():\n    with warns(snapshot()):\n        warn(\"some problem\")\n

Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/extra.py
@contextlib.contextmanager\ndef warns(\n    expected_warnings: SnapshotArg[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 `(line_number, 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, line_number, message)` if both `include_line` and `include_file` are `True`.\n    - `(line_number, 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 warnings import warn\n        from inline_snapshot import snapshot\n        from inline_snapshot.extra import warns\n\n\n        def test_warns():\n            with warns(include_line=True):\n                warn(\"some problem\")\n        ```\n\n    === \"--inline-snapshot=create\"\n\n        <!-- inline-snapshot: create fix outcome-passed=1 outcome-errors=1 -->\n        ``` python hl_lines=\"7\"\n        from warnings import warn\n        from inline_snapshot import snapshot\n        from inline_snapshot.extra import warns\n\n\n        def test_warns():\n            with warns([(8, \"UserWarning: some problem\")], include_line=True):\n                warn(\"some problem\")\n        ```\n\n    ??? info \"Limitation: CPython < 3.11\"\n        You have to use `snapshot(...)` as argument when you want to fix values on CPython < 3.11.\n        ``` python\n        def test_warns():\n            with warns(snapshot()):\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] == snapshot_arg(expected_warnings)\n
", │ │ │ │ "title": "warns(expected_warnings=..., /, include_line=False, include_file=False)" │ │ │ │ }, │ │ │ │ { │ │ │ │ "location": "fix_assert.html", │ │ │ │ "text": "", │ │ │ │ "title": "assert x == ..." │ │ │ │ }, │ │ │ │ @@ -1952,15 +1952,15 @@ │ │ │ │ { │ │ │ │ "location": "types.html#inline_snapshot.Category", │ │ │ │ "text": "

See categories

", │ │ │ │ "title": "Category = Literal['update', 'fix', 'create', 'trim', 'fix-assert'] module-attribute" │ │ │ │ }, │ │ │ │ { │ │ │ │ "location": "types.html#inline_snapshot.Snapshot", │ │ │ │ - "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 cpython3_3.14_inline-snapshot/build/inline_snapshot/_types.py
class Snapshot(Protocol[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    def __eq__(self, other: object, /) -> bool: ...  # pragma: no cover\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 cpython3_3.15_inline-snapshot/build/inline_snapshot/_types.py
class Snapshot(Protocol[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    def __eq__(self, other: object, /) -> bool: ...  # pragma: no cover\n
", │ │ │ │ "title": "Snapshot" │ │ │ │ }, │ │ │ │ { │ │ │ │ "location": "external/external.html", │ │ │ │ "text": "

Storing snapshots in the source code is the main feature of inline snapshots. This has the advantage that you can easily see changes in code reviews. However, it also has some drawbacks:

  • It is problematic to snapshot a large amount of data, as it consumes significant space in your tests.
  • Binary data or images are not human-readable in your tests.

external() solves this problem and integrates nicely with inline snapshots. It stores a reference to the external data in a special external() object, which can be used like snapshot().

There are different storage protocols, such as hash or uuid, and different file formats, such as .txt, .bin, and .json. It is also possible to implement custom file formats.

Example:

from inline_snapshot import external\n\n\ndef test_something():\n    # inline-snapshot can determine the correct file types\n    assert \"string\" == external()\n    assert b\"bytes\" == external()\n\n    # Data structures with lists and dictionaries are stored as JSON\n    assert [\"json\", \"like\", \"data\"] == external()\n\n    # You can also explicitly specify the storage protocol\n    assert \"other text\" == external(\"uuid:\")\n\n    # And the format (.json instead of the default .txt in this case)\n    assert \"other text\" == external(\"uuid:.json\")\n

inline-snapshot will then fill in the missing parts when you create your snapshots. It will keep your specified protocols and file types and generate names for your snapshots.

from inline_snapshot import external\n\n\ndef test_something():\n    # inline-snapshot can determine the correct file types\n    assert \"string\" == external(\"uuid:e3e70682-c209-4cac-a29f-6fbed82c07cd.txt\")\n    assert b\"bytes\" == external(\"uuid:f728b4fa-4248-4e3a-8a5d-2f346baa9455.bin\")\n\n    # Data structures with lists and dictionaries are stored as JSON\n    assert [\"json\", \"like\", \"data\"] == external(\n        \"uuid:eb1167b3-67a9-4378-bc65-c1e582e2e662.json\"\n    )\n\n    # You can also explicitly specify the storage protocol\n    assert \"other text\" == external(\n        \"uuid:f7c1bd87-4da5-4709-9471-3d60c8a70639.txt\"\n    )\n\n    # And the format (.json instead of the default .txt in this case)\n    assert \"other text\" == external(\n        \"uuid:e443df78-9558-467f-9ba9-1faf7a024204.json\"\n    )\n

The external() function can also be used inside other data structures.

from inline_snapshot import external, snapshot\n\n\ndef test_something():\n    assert [\"long text\\n\" * times for times in [1, 2, 1000]] == snapshot(\n        [..., ..., external()]\n    )\n
from inline_snapshot import external, snapshot\n\n\ndef test_something():\n    assert [\"long text\\n\" * times for times in [1, 2, 1000]] == snapshot(\n        [\n            \"long text\\n\",\n            \"\"\"\\\nlong text\nlong text\n\"\"\",\n            external(\"uuid:e3e70682-c209-4cac-a29f-6fbed82c07cd.txt\"),\n        ]\n    )\n
", │ │ │ │ "title": "external()" │ │ │ │ }, │ │ ├── ./usr/share/doc/python-inline-snapshot-doc/html/types.html │ │ │ @@ -1702,15 +1702,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ - Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/_types.py │ │ │ + Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/_types.py │ │ │
22
│ │ │  23
│ │ │  24
│ │ │  25
│ │ │  26
│ │ │  27
│ │ │  28
│ │ │ ├── html2text {}
│ │ │ │ @@ -103,15 +103,15 @@
│ │ │ │          assert len(value) == length
│ │ │ │  
│ │ │ │  
│ │ │ │  def test_container():
│ │ │ │      check_container([1, 2], value_repr=snapshot("[1, 2]"), length=snapshot(2))
│ │ │ │  
│ │ │ │      check_container({1, 1}, length=snapshot(1))
│ │ │ │ -Source code in cpython3_3.14_inline-snapshot/build/inline_snapshot/_types.py
│ │ │ │ +Source code in cpython3_3.15_inline-snapshot/build/inline_snapshot/_types.py
│ │ │ │     class Snapshot(Protocol[T]):
│ │ │ │  _2_2     """Can be used to annotate function arguments which accept snapshot
│ │ │ │  _2_3     values.
│ │ │ │  _2_4
│ │ │ │  _2_5     You can annotate function arguments with `Snapshot[T]` to declare that a
│ │ │ │  _2_6 snapshot-value can be passed as function argument.
│ │ │ │  _2_7     `Snapshot[T]` is a type alias for `T`, which allows you to pass `int`