| {"repo": "15r10nk/inline-snapshot", "n_pairs": 143, "version": "v2_function_scoped", "contexts": {"src/inline_snapshot/_code_repr.py::102": {"resolved_imports": ["src/inline_snapshot/_generator_utils.py", "src/inline_snapshot/_customize/_builder.py"], "used_names": ["Builder", "contextmanager", "mock", "only_value"], "enclosing_function": "mock_repr", "extracted_code": "# Source: src/inline_snapshot/_generator_utils.py\ndef only_value(gen):\n return split_gen(gen).value\n\n\n# Source: src/inline_snapshot/_customize/_builder.py\nclass Builder:\n _snapshot_context: AdapterContext\n _build_new_value: bool = False\n _recursive: bool = True\n\n def _get_handler_recursive(self, v) -> Custom:\n if self._recursive:\n return self._get_handler(v)\n else:\n return v\n\n def _get_handler(self, v) -> Custom:\n\n from inline_snapshot._global_state import state\n\n result = v\n\n while not isinstance(result, Custom):\n with compare_context():\n r = state().pm.hook.customize(\n value=result,\n builder=self,\n local_vars=self._local_vars,\n global_vars=self._global_vars,\n )\n if r is None:\n result = CustomCode(result)\n else:\n result = r\n\n result.__dict__[\"original_value\"] = v._eval() if isinstance(v, Custom) else v\n\n if not isinstance(v, Custom) and self._build_new_value:\n is_same = False\n v_eval = result._eval()\n\n if (\n hasattr(v, \"__pydantic_generic_metadata__\")\n and v.__pydantic_generic_metadata__[\"origin\"] == v_eval\n ):\n is_same = True\n\n if not is_same and v_eval == v:\n is_same = True\n\n if not is_same:\n raise UsageError(\n f\"\"\"\\\nCustomized value does not match original value:\n\noriginal_value={v!r}\n\ncustomized_value={result._eval()!r}\ncustomized_representation={result!r}\n\"\"\"\n )\n\n return result\n\n def create_external(\n self, value: Any, format: str | None = None, storage: str | None = None\n ):\n \"\"\"\n Creates a new `external()` with the given format and storage.\n \"\"\"\n\n return CustomExternal(value, format=format, storage=storage)\n\n def create_list(self, value: list) -> Custom:\n \"\"\"\n Creates an intermediate node for a list-expression which can be used as a result for your customization function.\n\n `create_list([1,2,3])` becomes `[1,2,3]` in the code.\n List elements don't have to be Custom nodes and are converted by inline-snapshot if needed.\n \"\"\"\n custom = [self._get_handler_recursive(v) for v in value]\n return CustomList(value=custom)\n\n def create_tuple(self, value: tuple) -> Custom:\n \"\"\"\n Creates an intermediate node for a tuple-expression which can be used as a result for your customization function.\n\n `create_tuple((1, 2, 3))` becomes `(1, 2, 3)` in the code.\n Tuple elements don't have to be Custom nodes and are converted by inline-snapshot if needed.\n \"\"\"\n custom = [self._get_handler_recursive(v) for v in value]\n return CustomTuple(value=custom)\n\n def with_default(self, value: Any, default: Any):\n \"\"\"\n Creates an intermediate node for a default value which can be used as an argument for create_call.\n\n Arguments are not included in the generated code when they match the actual default.\n The value doesn't have to be a Custom node and is converted by inline-snapshot if needed.\n \"\"\"\n if isinstance(default, Custom):\n raise UsageError(\"default value can not be an Custom value\")\n\n if value == default:\n return CustomDefault(value=self._get_handler_recursive(value))\n return value\n\n def create_call(\n self, function: Custom | Callable, posonly_args=[], kwargs={}\n ) -> Custom:\n \"\"\"\n Creates an intermediate node for a function call expression which can be used as a result for your customization function.\n\n `create_call(MyClass, [arg1, arg2], {'key': value})` becomes `MyClass(arg1, arg2, key=value)` in the code.\n Function, arguments, and keyword arguments don't have to be Custom nodes and are converted by inline-snapshot if needed.\n \"\"\"\n function = self._get_handler_recursive(function)\n posonly_args = [self._get_handler_recursive(arg) for arg in posonly_args]\n kwargs = {k: self._get_handler_recursive(arg) for k, arg in kwargs.items()}\n\n return CustomCall(\n function=function,\n args=posonly_args,\n kwargs=kwargs,\n )\n\n def create_dict(self, value: dict) -> Custom:\n \"\"\"\n Creates an intermediate node for a dict-expression which can be used as a result for your customization function.\n\n `create_dict({'key': 'value'})` becomes `{'key': 'value'}` in the code.\n Dict keys and values don't have to be Custom nodes and are converted by inline-snapshot if needed.\n \"\"\"\n custom = {\n self._get_handler_recursive(k): self._get_handler_recursive(v)\n for k, v in value.items()\n }\n return CustomDict(value=custom)\n\n @property\n def _local_vars(self):\n \"\"\"Get local vars from snapshot context.\"\"\"\n return self._snapshot_context.local_vars\n\n @property\n def _global_vars(self):\n \"\"\"Get global vars from snapshot context.\"\"\"\n return self._snapshot_context.global_vars\n\n def _build_import_vars(self, imports):\n \"\"\"Build import vars from imports parameter.\"\"\"\n import_vars = {}\n if imports:\n import importlib\n\n for imp in imports:\n if isinstance(imp, Import):\n # import module - makes top-level package available\n importlib.import_module(imp.module)\n top_level = imp.module.split(\".\")[0]\n import_vars[top_level] = importlib.import_module(top_level)\n elif isinstance(imp, ImportFrom):\n # from module import name\n module = importlib.import_module(imp.module)\n import_vars[imp.name] = getattr(module, imp.name)\n else:\n assert False\n return import_vars\n\n def create_code(\n self, code: str, *, imports: list[Import | ImportFrom] = []\n ) -> Custom:\n \"\"\"\n Creates an intermediate node for a value with a custom representation which can be used as a result for your customization function.\n\n `create_code('{value-1!r}+1')` becomes `4+1` in the code.\n Use this when you need to control the exact string representation of a value.\n\n Arguments:\n code: Custom string representation to evaluate. This is required and will be evaluated using the snapshot context.\n imports: Optional list of Import and ImportFrom objects to add required imports to the generated code.\n Example: `imports=[Import(\"os\"), ImportFrom(\"pathlib\", \"Path\")]`\n \"\"\"\n import_vars = None\n\n # Try direct variable lookup for simple identifiers (fastest)\n if code.isidentifier():\n # Direct lookup with proper precedence: local > import > global\n if code in self._local_vars:\n return CustomCode(self._local_vars[code], code, imports)\n\n # Build import vars only if needed\n import_vars = self._build_import_vars(imports)\n if code in import_vars:\n return CustomCode(import_vars[code], code, imports)\n\n if code in self._global_vars:\n return CustomCode(self._global_vars[code], code, imports)\n\n # Try ast.literal_eval for simple literals (fast and safe)\n try:\n import ast\n\n return CustomCode(ast.literal_eval(code), code, imports)\n except (ValueError, SyntaxError):\n # Fall back to eval with context for complex expressions\n # Build evaluation context with proper precedence: global < import < local\n if import_vars is None:\n import_vars = self._build_import_vars(imports)\n eval_context = {\n **self._global_vars,\n **import_vars,\n **self._local_vars,\n }\n return CustomCode(eval(code, eval_context), code, imports)", "n_imports_parsed": 10, "n_files_resolved": 2, "n_chars_extracted": 8232}, "src/inline_snapshot/_code_repr.py::116": {"resolved_imports": ["src/inline_snapshot/_generator_utils.py"], "used_names": [], "enclosing_function": "value_code_repr", "extracted_code": "", "n_imports_parsed": 9, "n_files_resolved": 1, "n_chars_extracted": 0}, "src/inline_snapshot/testing/_example.py::421": {"resolved_imports": ["src/inline_snapshot/_exceptions.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/_types.py"], "used_names": ["ArgumentParser", "Category", "Console", "Path", "Snapshot", "SnapshotSession", "StringIO", "TemporaryDirectory", "UsageError", "enter_snapshot_context", "leave_snapshot_context", "state", "sys", "traceback", "util"], "enclosing_function": "run_inline", "extracted_code": "# Source: src/inline_snapshot/_exceptions.py\nclass UsageError(Exception):\n pass\n\n\n# Source: src/inline_snapshot/_global_state.py\ndef enter_snapshot_context():\n global _current\n latest = _current\n _latest_global_states.append(_current)\n _current = State()\n _current.all_formats = dict(latest.all_formats)\n _current.config = deepcopy(latest.config)\n\n from .plugin._spec import InlineSnapshotPluginSpec\n\n _current.pm.add_hookspecs(InlineSnapshotPluginSpec)\n\n from .plugin._default_plugin import InlineSnapshotPlugin\n\n _current.pm.register(InlineSnapshotPlugin())\n\n try:\n from .plugin._default_plugin import InlineSnapshotAttrsPlugin\n except ImportError: # pragma: no cover\n pass\n else:\n _current.pm.register(InlineSnapshotAttrsPlugin())\n\n try:\n from .plugin._default_plugin import InlineSnapshotPydanticPlugin\n except ImportError: # pragma: no cover\n pass\n else:\n _current.pm.register(InlineSnapshotPydanticPlugin())\n\n try:\n from .plugin._default_plugin import InlineSnapshotDirtyEqualsPlugin\n except ImportError: # pragma: no cover\n pass\n else:\n _current.pm.register(InlineSnapshotDirtyEqualsPlugin())\n\n _current.pm.load_setuptools_entrypoints(inline_snapshot_plugin_name)\n\n\n# Source: src/inline_snapshot/_types.py\nCategory = Literal[\"update\", \"fix\", \"create\", \"trim\", \"fix-assert\"]", "n_imports_parsed": 25, "n_files_resolved": 3, "n_chars_extracted": 1409}, "src/inline_snapshot/testing/_example.py::535": {"resolved_imports": ["src/inline_snapshot/_exceptions.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/_types.py"], "used_names": ["Path", "Snapshot", "TemporaryDirectory", "os", "platform", "sys"], "enclosing_function": "run_pytest", "extracted_code": "", "n_imports_parsed": 25, "n_files_resolved": 3, "n_chars_extracted": 0}, "src/inline_snapshot/testing/_example.py::557": {"resolved_imports": ["src/inline_snapshot/_exceptions.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/_types.py"], "used_names": ["Path", "Snapshot", "TemporaryDirectory", "os", "platform", "sys"], "enclosing_function": "run_pytest", "extracted_code": "", "n_imports_parsed": 25, "n_files_resolved": 3, "n_chars_extracted": 0}, "src/inline_snapshot/testing/_example.py::518": {"resolved_imports": ["src/inline_snapshot/_exceptions.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/_types.py"], "used_names": ["Path", "Snapshot", "TemporaryDirectory", "os", "platform", "sys"], "enclosing_function": "run_pytest", "extracted_code": "", "n_imports_parsed": 25, "n_files_resolved": 3, "n_chars_extracted": 0}, "src/inline_snapshot/testing/_example.py::404": {"resolved_imports": ["src/inline_snapshot/_exceptions.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/_types.py"], "used_names": ["ArgumentParser", "Category", "Console", "Path", "Snapshot", "SnapshotSession", "StringIO", "TemporaryDirectory", "UsageError", "enter_snapshot_context", "leave_snapshot_context", "state", "sys", "traceback", "util"], "enclosing_function": "run_inline", "extracted_code": "# Source: src/inline_snapshot/_exceptions.py\nclass UsageError(Exception):\n pass\n\n\n# Source: src/inline_snapshot/_global_state.py\ndef enter_snapshot_context():\n global _current\n latest = _current\n _latest_global_states.append(_current)\n _current = State()\n _current.all_formats = dict(latest.all_formats)\n _current.config = deepcopy(latest.config)\n\n from .plugin._spec import InlineSnapshotPluginSpec\n\n _current.pm.add_hookspecs(InlineSnapshotPluginSpec)\n\n from .plugin._default_plugin import InlineSnapshotPlugin\n\n _current.pm.register(InlineSnapshotPlugin())\n\n try:\n from .plugin._default_plugin import InlineSnapshotAttrsPlugin\n except ImportError: # pragma: no cover\n pass\n else:\n _current.pm.register(InlineSnapshotAttrsPlugin())\n\n try:\n from .plugin._default_plugin import InlineSnapshotPydanticPlugin\n except ImportError: # pragma: no cover\n pass\n else:\n _current.pm.register(InlineSnapshotPydanticPlugin())\n\n try:\n from .plugin._default_plugin import InlineSnapshotDirtyEqualsPlugin\n except ImportError: # pragma: no cover\n pass\n else:\n _current.pm.register(InlineSnapshotDirtyEqualsPlugin())\n\n _current.pm.load_setuptools_entrypoints(inline_snapshot_plugin_name)\n\n\n# Source: src/inline_snapshot/_types.py\nCategory = Literal[\"update\", \"fix\", \"create\", \"trim\", \"fix-assert\"]", "n_imports_parsed": 25, "n_files_resolved": 3, "n_chars_extracted": 1409}, "src/inline_snapshot/testing/_example.py::411": {"resolved_imports": ["src/inline_snapshot/_exceptions.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/_types.py"], "used_names": ["ArgumentParser", "Category", "Console", "Path", "Snapshot", "SnapshotSession", "StringIO", "TemporaryDirectory", "UsageError", "enter_snapshot_context", "leave_snapshot_context", "state", "sys", "traceback", "util"], "enclosing_function": "run_inline", "extracted_code": "# Source: src/inline_snapshot/_exceptions.py\nclass UsageError(Exception):\n pass\n\n\n# Source: src/inline_snapshot/_global_state.py\ndef enter_snapshot_context():\n global _current\n latest = _current\n _latest_global_states.append(_current)\n _current = State()\n _current.all_formats = dict(latest.all_formats)\n _current.config = deepcopy(latest.config)\n\n from .plugin._spec import InlineSnapshotPluginSpec\n\n _current.pm.add_hookspecs(InlineSnapshotPluginSpec)\n\n from .plugin._default_plugin import InlineSnapshotPlugin\n\n _current.pm.register(InlineSnapshotPlugin())\n\n try:\n from .plugin._default_plugin import InlineSnapshotAttrsPlugin\n except ImportError: # pragma: no cover\n pass\n else:\n _current.pm.register(InlineSnapshotAttrsPlugin())\n\n try:\n from .plugin._default_plugin import InlineSnapshotPydanticPlugin\n except ImportError: # pragma: no cover\n pass\n else:\n _current.pm.register(InlineSnapshotPydanticPlugin())\n\n try:\n from .plugin._default_plugin import InlineSnapshotDirtyEqualsPlugin\n except ImportError: # pragma: no cover\n pass\n else:\n _current.pm.register(InlineSnapshotDirtyEqualsPlugin())\n\n _current.pm.load_setuptools_entrypoints(inline_snapshot_plugin_name)\n\n\n# Source: src/inline_snapshot/_types.py\nCategory = Literal[\"update\", \"fix\", \"create\", \"trim\", \"fix-assert\"]", "n_imports_parsed": 25, "n_files_resolved": 3, "n_chars_extracted": 1409}, "src/inline_snapshot/testing/_example.py::573": {"resolved_imports": ["src/inline_snapshot/_exceptions.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/_types.py"], "used_names": ["Path", "Snapshot", "TemporaryDirectory", "os", "platform", "sys"], "enclosing_function": "run_pytest", "extracted_code": "", "n_imports_parsed": 25, "n_files_resolved": 3, "n_chars_extracted": 0}, "src/inline_snapshot/testing/_example.py::427": {"resolved_imports": ["src/inline_snapshot/_exceptions.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/_types.py"], "used_names": ["ArgumentParser", "Category", "Console", "Path", "Snapshot", "SnapshotSession", "StringIO", "TemporaryDirectory", "UsageError", "enter_snapshot_context", "leave_snapshot_context", "state", "sys", "traceback", "util"], "enclosing_function": "run_inline", "extracted_code": "# Source: src/inline_snapshot/_exceptions.py\nclass UsageError(Exception):\n pass\n\n\n# Source: src/inline_snapshot/_global_state.py\ndef enter_snapshot_context():\n global _current\n latest = _current\n _latest_global_states.append(_current)\n _current = State()\n _current.all_formats = dict(latest.all_formats)\n _current.config = deepcopy(latest.config)\n\n from .plugin._spec import InlineSnapshotPluginSpec\n\n _current.pm.add_hookspecs(InlineSnapshotPluginSpec)\n\n from .plugin._default_plugin import InlineSnapshotPlugin\n\n _current.pm.register(InlineSnapshotPlugin())\n\n try:\n from .plugin._default_plugin import InlineSnapshotAttrsPlugin\n except ImportError: # pragma: no cover\n pass\n else:\n _current.pm.register(InlineSnapshotAttrsPlugin())\n\n try:\n from .plugin._default_plugin import InlineSnapshotPydanticPlugin\n except ImportError: # pragma: no cover\n pass\n else:\n _current.pm.register(InlineSnapshotPydanticPlugin())\n\n try:\n from .plugin._default_plugin import InlineSnapshotDirtyEqualsPlugin\n except ImportError: # pragma: no cover\n pass\n else:\n _current.pm.register(InlineSnapshotDirtyEqualsPlugin())\n\n _current.pm.load_setuptools_entrypoints(inline_snapshot_plugin_name)\n\n\n# Source: src/inline_snapshot/_types.py\nCategory = Literal[\"update\", \"fix\", \"create\", \"trim\", \"fix-assert\"]", "n_imports_parsed": 25, "n_files_resolved": 3, "n_chars_extracted": 1409}, "src/inline_snapshot/testing/_example.py::576": {"resolved_imports": ["src/inline_snapshot/_exceptions.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/_types.py"], "used_names": ["Path", "Snapshot", "TemporaryDirectory", "os", "platform", "sys"], "enclosing_function": "run_pytest", "extracted_code": "", "n_imports_parsed": 25, "n_files_resolved": 3, "n_chars_extracted": 0}, "testing/generate_tests.py::37": {"resolved_imports": ["src/inline_snapshot/_exceptions.py"], "used_names": ["random"], "enclosing_function": "gen_new_value", "extracted_code": "", "n_imports_parsed": 6, "n_files_resolved": 1, "n_chars_extracted": 0}, "tests/conftest.py::61": {"resolved_imports": ["src/inline_snapshot/_external/__init__.py", "src/inline_snapshot/_change.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_format.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/_rewrite_code.py", "src/inline_snapshot/_types.py"], "used_names": [], "enclosing_function": "w", "extracted_code": "", "n_imports_parsed": 26, "n_files_resolved": 7, "n_chars_extracted": 0}, "tests/conftest.py::383": {"resolved_imports": ["src/inline_snapshot/_external/__init__.py", "src/inline_snapshot/_change.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_format.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/_rewrite_code.py", "src/inline_snapshot/_types.py"], "used_names": [], "enclosing_function": "source", "extracted_code": "", "n_imports_parsed": 26, "n_files_resolved": 7, "n_chars_extracted": 0}, "tests/conftest.py::60": {"resolved_imports": ["src/inline_snapshot/_external/__init__.py", "src/inline_snapshot/_change.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_format.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/_rewrite_code.py", "src/inline_snapshot/_types.py"], "used_names": [], "enclosing_function": "w", "extracted_code": "", "n_imports_parsed": 26, "n_files_resolved": 7, "n_chars_extracted": 0}, "tests/conftest.py::62": {"resolved_imports": ["src/inline_snapshot/_external/__init__.py", "src/inline_snapshot/_change.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_format.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/_rewrite_code.py", "src/inline_snapshot/_types.py"], "used_names": [], "enclosing_function": "w", "extracted_code": "", "n_imports_parsed": 26, "n_files_resolved": 7, "n_chars_extracted": 0}, "tests/test_align.py::10": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_align.py"], "used_names": ["add_x", "align", "snapshot"], "enclosing_function": "test_align", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)\n\n\n# Source: src/inline_snapshot/_align.py\ndef add_x(track):\n \"\"\"Replaces an `id` with the same number of insertions and deletions with\n x.\"\"\"\n groups = [(c, len(list(v))) for c, v in groupby(track)]\n i = 0\n result = \"\"\n while i < len(groups):\n g = groups[i]\n if i == len(groups) - 1:\n result += g[0] * g[1]\n break\n\n ng = groups[i + 1]\n if g[0] == \"d\" and ng[0] == \"i\" and g[1] == ng[1]:\n result += \"x\" * g[1]\n i += 1\n else:\n result += g[0] * g[1]\n\n i += 1\n\n return result", "n_imports_parsed": 3, "n_files_resolved": 2, "n_chars_extracted": 1260}, "tests/test_align.py::7": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_align.py"], "used_names": ["add_x", "align", "snapshot"], "enclosing_function": "test_align", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)\n\n\n# Source: src/inline_snapshot/_align.py\ndef add_x(track):\n \"\"\"Replaces an `id` with the same number of insertions and deletions with\n x.\"\"\"\n groups = [(c, len(list(v))) for c, v in groupby(track)]\n i = 0\n result = \"\"\n while i < len(groups):\n g = groups[i]\n if i == len(groups) - 1:\n result += g[0] * g[1]\n break\n\n ng = groups[i + 1]\n if g[0] == \"d\" and ng[0] == \"i\" and g[1] == ng[1]:\n result += \"x\" * g[1]\n i += 1\n else:\n result += g[0] * g[1]\n\n i += 1\n\n return result", "n_imports_parsed": 3, "n_files_resolved": 2, "n_chars_extracted": 1260}, "tests/test_align.py::9": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_align.py"], "used_names": ["add_x", "align", "snapshot"], "enclosing_function": "test_align", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)\n\n\n# Source: src/inline_snapshot/_align.py\ndef add_x(track):\n \"\"\"Replaces an `id` with the same number of insertions and deletions with\n x.\"\"\"\n groups = [(c, len(list(v))) for c, v in groupby(track)]\n i = 0\n result = \"\"\n while i < len(groups):\n g = groups[i]\n if i == len(groups) - 1:\n result += g[0] * g[1]\n break\n\n ng = groups[i + 1]\n if g[0] == \"d\" and ng[0] == \"i\" and g[1] == ng[1]:\n result += \"x\" * g[1]\n i += 1\n else:\n result += g[0] * g[1]\n\n i += 1\n\n return result", "n_imports_parsed": 3, "n_files_resolved": 2, "n_chars_extracted": 1260}, "tests/test_change.py::42": {"resolved_imports": ["src/inline_snapshot/_change.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_rewrite_code.py", "src/inline_snapshot/_source_file.py"], "used_names": ["ChangeRecorder", "Source", "SourceFile", "apply_all", "ast"], "enclosing_function": "w", "extracted_code": "# Source: src/inline_snapshot/_rewrite_code.py\nclass ChangeRecorder:\n\n def __init__(self):\n self._source_files = defaultdict(SourceFile)\n self._changes = []\n\n def get_source(self, filename) -> SourceFile:\n filename = pathlib.Path(filename)\n if filename not in self._source_files:\n self._source_files[filename] = SourceFile(filename)\n\n return self._source_files[filename]\n\n def files(self) -> Iterable[SourceFile]:\n return self._source_files.values()\n\n def new_change(self):\n return Change(self)\n\n def num_fixes(self):\n changes = set()\n for file in self._source_files.values():\n changes.update(change.change_id for change in file.replacements)\n return len(changes)\n\n def fix_all(self):\n for file in self._source_files.values():\n file.rewrite()\n\n def virtual_write(self):\n for file in self._source_files.values():\n file.virtual_write()\n\n def dump(self): # pragma: no cover\n for file in self._source_files.values():\n print(\"file:\", file.filename)\n for change in file.replacements:\n print(\" change:\", change)\n\n\n# Source: src/inline_snapshot/_source_file.py\nclass SourceFile:\n _source: Source\n\n def __init__(self, source: Source):\n self._source = source\n\n @property\n def filename(self) -> str:\n return self._source.filename\n\n def _format(self, code):\n if self._source is None or enforce_formatting():\n return code\n else:\n return format_code(code, Path(self._source.filename))\n\n def format_expression(self, code: str) -> str:\n return self._format(code).strip()\n\n def asttokens(self):\n return self._source.asttokens()\n\n def code_changed(self, old_node, new_code):\n\n if old_node is None:\n return False\n\n return self._token_of_node(old_node) != _token_of_code(new_code)\n\n def _token_of_node(self, node):\n\n return list(\n normalize(\n [\n simple_token(t.type, t.string)\n for t in self._source.asttokens().get_tokens(node)\n if t.type not in ignore_tokens\n ]\n )\n )", "n_imports_parsed": 10, "n_files_resolved": 4, "n_chars_extracted": 2286}, "tests/test_code_repr.py::368": {"resolved_imports": ["src/inline_snapshot/__init__.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_sentinels.py"], "used_names": ["OrderedDict", "UserDict", "UserList", "code_repr", "pytest", "undefined"], "enclosing_function": "test_datatypes", "extracted_code": "# Source: src/inline_snapshot/_sentinels.py\nundefined = ...", "n_imports_parsed": 15, "n_files_resolved": 3, "n_chars_extracted": 59}, "tests/test_code_repr.py::384": {"resolved_imports": ["src/inline_snapshot/__init__.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_sentinels.py"], "used_names": ["Counter", "code_repr", "snapshot"], "enclosing_function": "test_datatypes_explicit", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 15, "n_files_resolved": 3, "n_chars_extracted": 670}, "tests/test_code_repr.py::163": {"resolved_imports": ["src/inline_snapshot/__init__.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_sentinels.py"], "used_names": ["HasRepr"], "enclosing_function": "test_hasrepr_type", "extracted_code": "# Source: src/inline_snapshot/__init__.py\nfrom inline_snapshot._external._diff import TextDiff\n\nfrom ._code_repr import HasRepr\nfrom ._code_repr import customize_repr\nfrom ._exceptions import UsageError\nfrom ._external._external import external\nfrom ._external._external_file import external_file\nfrom ._external._format._protocol import Format\nfrom ._external._format._protocol import register_format\nfrom ._external._format._protocol import register_format_alias\nfrom ._external._outsource import outsource\nfrom ._get_snapshot_value import get_snapshot_value\n\n \"outsource\",\n \"customize_repr\",\n \"HasRepr\",\n \"Is\",\n \"Category\",\n \"Snapshot\",\n \"UsageError\",\n \"register_format_alias\",\n \"register_format\",\n \"Format\",\n \"TextDiff\",\n \"BinaryDiff\",", "n_imports_parsed": 15, "n_files_resolved": 3, "n_chars_extracted": 775}, "tests/test_code_repr.py::383": {"resolved_imports": ["src/inline_snapshot/__init__.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_sentinels.py"], "used_names": ["Counter", "code_repr", "snapshot"], "enclosing_function": "test_datatypes_explicit", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 15, "n_files_resolved": 3, "n_chars_extracted": 670}, "tests/test_code_repr.py::382": {"resolved_imports": ["src/inline_snapshot/__init__.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_sentinels.py"], "used_names": ["Counter", "code_repr", "snapshot"], "enclosing_function": "test_datatypes_explicit", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 15, "n_files_resolved": 3, "n_chars_extracted": 670}, "tests/test_code_repr.py::403": {"resolved_imports": ["src/inline_snapshot/__init__.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_sentinels.py"], "used_names": ["code_repr", "snapshot"], "enclosing_function": "test_fake_tuple1", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 15, "n_files_resolved": 3, "n_chars_extracted": 670}, "tests/test_code_repr.py::386": {"resolved_imports": ["src/inline_snapshot/__init__.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_sentinels.py"], "used_names": ["Counter", "code_repr", "snapshot"], "enclosing_function": "test_datatypes_explicit", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 15, "n_files_resolved": 3, "n_chars_extracted": 670}, "tests/test_code_repr.py::372": {"resolved_imports": ["src/inline_snapshot/__init__.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_sentinels.py"], "used_names": ["code_repr", "snapshot"], "enclosing_function": "test_set", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 15, "n_files_resolved": 3, "n_chars_extracted": 670}, "tests/test_code_repr.py::390": {"resolved_imports": ["src/inline_snapshot/__init__.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_sentinels.py"], "used_names": ["Counter", "code_repr", "snapshot"], "enclosing_function": "test_datatypes_explicit", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 15, "n_files_resolved": 3, "n_chars_extracted": 670}, "tests/test_code_repr.py::376": {"resolved_imports": ["src/inline_snapshot/__init__.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_sentinels.py"], "used_names": ["code_repr", "snapshot"], "enclosing_function": "test_set", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 15, "n_files_resolved": 3, "n_chars_extracted": 670}, "tests/test_code_repr.py::373": {"resolved_imports": ["src/inline_snapshot/__init__.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_sentinels.py"], "used_names": ["code_repr", "snapshot"], "enclosing_function": "test_set", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 15, "n_files_resolved": 3, "n_chars_extracted": 670}, "tests/test_code_repr.py::249": {"resolved_imports": ["src/inline_snapshot/__init__.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_sentinels.py"], "used_names": ["snapshot"], "enclosing_function": "test_type", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 15, "n_files_resolved": 3, "n_chars_extracted": 670}, "tests/test_code_repr.py::215": {"resolved_imports": ["src/inline_snapshot/__init__.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_sentinels.py"], "used_names": ["snapshot"], "enclosing_function": "test_flag", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 15, "n_files_resolved": 3, "n_chars_extracted": 670}, "tests/test_code_repr.py::171": {"resolved_imports": ["src/inline_snapshot/__init__.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_sentinels.py"], "used_names": ["snapshot"], "enclosing_function": "test_enum_in_dataclass", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 15, "n_files_resolved": 3, "n_chars_extracted": 670}, "tests/test_docs.py::72": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_align.py", "src/inline_snapshot/_external/_external_file.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py", "src/inline_snapshot/version.py"], "used_names": ["List", "Optional", "Path", "external_file", "re", "textwrap"], "enclosing_function": "map_code_blocks", "extracted_code": "# Source: src/inline_snapshot/_external/_external_file.py\ndef external_file(path: Union[Path, str], *, format: Optional[str] = None):\n \"\"\"\n Arguments:\n path: the path to the external file, relative to the directory of the current file.\n format: overwrite the format handler which should be used to load and save the content.\n It can be used to treat markdown files as text files with `format=\".txt\"` for example.\n \"\"\"\n path = Path(path)\n\n if not path.is_absolute():\n from inspect import currentframe\n\n frame = currentframe()\n assert frame\n frame = frame.f_back\n assert frame\n path = Path(frame.f_code.co_filename).parent / path\n\n path = path.resolve()\n\n if format is None:\n format = path.suffix\n\n format_handler = get_format_handler_from_suffix(format)\n\n if not state().active:\n return format_handler.decode(path)\n\n key = (\"file\", path)\n if key not in state().snapshots:\n new = ExternalFile(path, format_handler)\n state().snapshots[key] = new\n else:\n new = cast(ExternalFile, state().snapshots[key])\n\n assert new._format.suffix == format_handler.suffix\n\n return new", "n_imports_parsed": 25, "n_files_resolved": 7, "n_chars_extracted": 1213}, "tests/test_docs.py::173": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_align.py", "src/inline_snapshot/_external/_external_file.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py", "src/inline_snapshot/version.py"], "used_names": ["raises", "snapshot", "snapshot_env"], "enclosing_function": "test_doc", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)\n\n\n# Source: src/inline_snapshot/_global_state.py\ndef snapshot_env() -> Generator[State]:\n from ._external._storage._hash import HashStorage\n\n old = _current\n\n enter_snapshot_context()\n\n try:\n with TemporaryDirectory() as dir:\n _current.all_storages = dict(old.all_storages)\n _current.all_storages[\"hash\"] = HashStorage(dir)\n\n yield _current\n finally:\n leave_snapshot_context()\n\n\n# Source: src/inline_snapshot/extra.py\ndef raises(exception: Snapshot[str]):\n \"\"\"Check that an exception is raised.\n\n Parameters:\n exception: Snapshot that is compared with `#!python f\"{type}: {message}\"` if an exception occurs, or `#!python \"<no exception>\"` if no exception is 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 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(snapshot(\"ZeroDivisionError: division by zero\")):\n 1 / 0\n ```\n \"\"\"\n\n try:\n yield\n except BaseException 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_imports_parsed": 25, "n_files_resolved": 7, "n_chars_extracted": 2402}, "tests/test_docs.py::137": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_align.py", "src/inline_snapshot/_external/_external_file.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py", "src/inline_snapshot/version.py"], "used_names": ["List", "Optional", "Path", "external_file", "re", "textwrap"], "enclosing_function": "map_code_blocks", "extracted_code": "# Source: src/inline_snapshot/_external/_external_file.py\ndef external_file(path: Union[Path, str], *, format: Optional[str] = None):\n \"\"\"\n Arguments:\n path: the path to the external file, relative to the directory of the current file.\n format: overwrite the format handler which should be used to load and save the content.\n It can be used to treat markdown files as text files with `format=\".txt\"` for example.\n \"\"\"\n path = Path(path)\n\n if not path.is_absolute():\n from inspect import currentframe\n\n frame = currentframe()\n assert frame\n frame = frame.f_back\n assert frame\n path = Path(frame.f_code.co_filename).parent / path\n\n path = path.resolve()\n\n if format is None:\n format = path.suffix\n\n format_handler = get_format_handler_from_suffix(format)\n\n if not state().active:\n return format_handler.decode(path)\n\n key = (\"file\", path)\n if key not in state().snapshots:\n new = ExternalFile(path, format_handler)\n state().snapshots[key] = new\n else:\n new = cast(ExternalFile, state().snapshots[key])\n\n assert new._format.suffix == format_handler.suffix\n\n return new", "n_imports_parsed": 25, "n_files_resolved": 7, "n_chars_extracted": 1213}, "tests/test_docs.py::180": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_align.py", "src/inline_snapshot/_external/_external_file.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py", "src/inline_snapshot/version.py"], "used_names": ["raises", "snapshot", "snapshot_env"], "enclosing_function": "test_doc", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)\n\n\n# Source: src/inline_snapshot/_global_state.py\ndef snapshot_env() -> Generator[State]:\n from ._external._storage._hash import HashStorage\n\n old = _current\n\n enter_snapshot_context()\n\n try:\n with TemporaryDirectory() as dir:\n _current.all_storages = dict(old.all_storages)\n _current.all_storages[\"hash\"] = HashStorage(dir)\n\n yield _current\n finally:\n leave_snapshot_context()\n\n\n# Source: src/inline_snapshot/extra.py\ndef raises(exception: Snapshot[str]):\n \"\"\"Check that an exception is raised.\n\n Parameters:\n exception: Snapshot that is compared with `#!python f\"{type}: {message}\"` if an exception occurs, or `#!python \"<no exception>\"` if no exception is 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 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(snapshot(\"ZeroDivisionError: division by zero\")):\n 1 / 0\n ```\n \"\"\"\n\n try:\n yield\n except BaseException 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_imports_parsed": 25, "n_files_resolved": 7, "n_chars_extracted": 2402}, "tests/test_get_snapshot_value.py::38": {"resolved_imports": ["src/inline_snapshot/_is.py", "src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_get_snapshot_value.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_global_state.py"], "used_names": ["get_snapshot_value", "snapshot"], "enclosing_function": "test_snapshot", "extracted_code": "# Source: src/inline_snapshot/_get_snapshot_value.py\ndef get_snapshot_value(snapshot_value: Snapshot[T]) -> T:\n \"\"\"\n Extracts and returns the raw value stored inside a snapshot, removing all inline-snapshot-specific\n wrappers such as those generated by `external()`, `Is()`, or `snapshot()`.\n\n This function is primarily intended for extension authors who need direct access to the value\n of a previously stored snapshot. For standard test assertions, prefer using the snapshot directly.\n\n Args:\n snapshot_value: The snapshot object from which to extract the value.\n\n Returns:\n The unwrapped value contained in the snapshot.\n\n Example:\n ``` python\n from inline_snapshot import external, snapshot, get_snapshot_value\n\n s = snapshot([0, external(\"uuid:e3e70682-c209-4cac-a29f-6fbed82c07cd.json\")])\n\n if record:\n # Store value\n assert s == [0, 5]\n else:\n # Use value from snapshot\n value = get_snapshot_value(s)\n # ... do something with value\n ```\n\n <!-- TODO: Find a way to test this code in the docs -->\n \"\"\"\n if state().active:\n return unwrap(snapshot_value)[0]\n else:\n return snapshot_value\n\n\n# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 9, "n_files_resolved": 6, "n_chars_extracted": 1925}, "tests/test_get_snapshot_value.py::46": {"resolved_imports": ["src/inline_snapshot/_is.py", "src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_get_snapshot_value.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_global_state.py"], "used_names": ["external", "get_snapshot_value", "snapshot"], "enclosing_function": "test_snapshot_external", "extracted_code": "# Source: src/inline_snapshot/_external/_external.py\ndef external(name: str | None = None):\n return create_snapshot(External, name)\n\n\n# Source: src/inline_snapshot/_get_snapshot_value.py\ndef get_snapshot_value(snapshot_value: Snapshot[T]) -> T:\n \"\"\"\n Extracts and returns the raw value stored inside a snapshot, removing all inline-snapshot-specific\n wrappers such as those generated by `external()`, `Is()`, or `snapshot()`.\n\n This function is primarily intended for extension authors who need direct access to the value\n of a previously stored snapshot. For standard test assertions, prefer using the snapshot directly.\n\n Args:\n snapshot_value: The snapshot object from which to extract the value.\n\n Returns:\n The unwrapped value contained in the snapshot.\n\n Example:\n ``` python\n from inline_snapshot import external, snapshot, get_snapshot_value\n\n s = snapshot([0, external(\"uuid:e3e70682-c209-4cac-a29f-6fbed82c07cd.json\")])\n\n if record:\n # Store value\n assert s == [0, 5]\n else:\n # Use value from snapshot\n value = get_snapshot_value(s)\n # ... do something with value\n ```\n\n <!-- TODO: Find a way to test this code in the docs -->\n \"\"\"\n if state().active:\n return unwrap(snapshot_value)[0]\n else:\n return snapshot_value\n\n\n# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 9, "n_files_resolved": 6, "n_chars_extracted": 2062}, "tests/test_get_snapshot_value.py::40": {"resolved_imports": ["src/inline_snapshot/_is.py", "src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_get_snapshot_value.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_global_state.py"], "used_names": ["get_snapshot_value", "snapshot"], "enclosing_function": "test_snapshot", "extracted_code": "# Source: src/inline_snapshot/_get_snapshot_value.py\ndef get_snapshot_value(snapshot_value: Snapshot[T]) -> T:\n \"\"\"\n Extracts and returns the raw value stored inside a snapshot, removing all inline-snapshot-specific\n wrappers such as those generated by `external()`, `Is()`, or `snapshot()`.\n\n This function is primarily intended for extension authors who need direct access to the value\n of a previously stored snapshot. For standard test assertions, prefer using the snapshot directly.\n\n Args:\n snapshot_value: The snapshot object from which to extract the value.\n\n Returns:\n The unwrapped value contained in the snapshot.\n\n Example:\n ``` python\n from inline_snapshot import external, snapshot, get_snapshot_value\n\n s = snapshot([0, external(\"uuid:e3e70682-c209-4cac-a29f-6fbed82c07cd.json\")])\n\n if record:\n # Store value\n assert s == [0, 5]\n else:\n # Use value from snapshot\n value = get_snapshot_value(s)\n # ... do something with value\n ```\n\n <!-- TODO: Find a way to test this code in the docs -->\n \"\"\"\n if state().active:\n return unwrap(snapshot_value)[0]\n else:\n return snapshot_value\n\n\n# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 9, "n_files_resolved": 6, "n_chars_extracted": 1925}, "tests/test_get_snapshot_value.py::48": {"resolved_imports": ["src/inline_snapshot/_is.py", "src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_get_snapshot_value.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_global_state.py"], "used_names": ["external", "get_snapshot_value", "snapshot"], "enclosing_function": "test_snapshot_external", "extracted_code": "# Source: src/inline_snapshot/_external/_external.py\ndef external(name: str | None = None):\n return create_snapshot(External, name)\n\n\n# Source: src/inline_snapshot/_get_snapshot_value.py\ndef get_snapshot_value(snapshot_value: Snapshot[T]) -> T:\n \"\"\"\n Extracts and returns the raw value stored inside a snapshot, removing all inline-snapshot-specific\n wrappers such as those generated by `external()`, `Is()`, or `snapshot()`.\n\n This function is primarily intended for extension authors who need direct access to the value\n of a previously stored snapshot. For standard test assertions, prefer using the snapshot directly.\n\n Args:\n snapshot_value: The snapshot object from which to extract the value.\n\n Returns:\n The unwrapped value contained in the snapshot.\n\n Example:\n ``` python\n from inline_snapshot import external, snapshot, get_snapshot_value\n\n s = snapshot([0, external(\"uuid:e3e70682-c209-4cac-a29f-6fbed82c07cd.json\")])\n\n if record:\n # Store value\n assert s == [0, 5]\n else:\n # Use value from snapshot\n value = get_snapshot_value(s)\n # ... do something with value\n ```\n\n <!-- TODO: Find a way to test this code in the docs -->\n \"\"\"\n if state().active:\n return unwrap(snapshot_value)[0]\n else:\n return snapshot_value\n\n\n# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 9, "n_files_resolved": 6, "n_chars_extracted": 2062}, "tests/test_get_snapshot_value.py::87": {"resolved_imports": ["src/inline_snapshot/_is.py", "src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_get_snapshot_value.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_global_state.py"], "used_names": ["external", "get_snapshot_value", "outsource", "snapshot"], "enclosing_function": "test_dataclass", "extracted_code": "# Source: src/inline_snapshot/_external/_external.py\ndef external(name: str | None = None):\n return create_snapshot(External, name)\n\n\n# Source: src/inline_snapshot/_get_snapshot_value.py\ndef get_snapshot_value(snapshot_value: Snapshot[T]) -> T:\n \"\"\"\n Extracts and returns the raw value stored inside a snapshot, removing all inline-snapshot-specific\n wrappers such as those generated by `external()`, `Is()`, or `snapshot()`.\n\n This function is primarily intended for extension authors who need direct access to the value\n of a previously stored snapshot. For standard test assertions, prefer using the snapshot directly.\n\n Args:\n snapshot_value: The snapshot object from which to extract the value.\n\n Returns:\n The unwrapped value contained in the snapshot.\n\n Example:\n ``` python\n from inline_snapshot import external, snapshot, get_snapshot_value\n\n s = snapshot([0, external(\"uuid:e3e70682-c209-4cac-a29f-6fbed82c07cd.json\")])\n\n if record:\n # Store value\n assert s == [0, 5]\n else:\n # Use value from snapshot\n value = get_snapshot_value(s)\n # ... do something with value\n ```\n\n <!-- TODO: Find a way to test this code in the docs -->\n \"\"\"\n if state().active:\n return unwrap(snapshot_value)[0]\n else:\n return snapshot_value\n\n\n# Source: src/inline_snapshot/_external/_outsource.py\ndef outsource(data: Any, suffix: str | None = None, storage: str | None = None) -> Any:\n if suffix and suffix[0] != \".\":\n raise ValueError(\"suffix has to start with a '.' like '.png'\")\n\n if not state().active:\n return data\n\n # check if the suffix/datatype is supported\n get_format_handler(data, suffix or \"\")\n\n return Outsourced(data, suffix, storage)\n\n\n# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 9, "n_files_resolved": 6, "n_chars_extracted": 2499}, "tests/test_get_snapshot_value.py::89": {"resolved_imports": ["src/inline_snapshot/_is.py", "src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_get_snapshot_value.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_global_state.py"], "used_names": ["external", "get_snapshot_value", "outsource", "snapshot"], "enclosing_function": "test_dataclass", "extracted_code": "# Source: src/inline_snapshot/_external/_external.py\ndef external(name: str | None = None):\n return create_snapshot(External, name)\n\n\n# Source: src/inline_snapshot/_get_snapshot_value.py\ndef get_snapshot_value(snapshot_value: Snapshot[T]) -> T:\n \"\"\"\n Extracts and returns the raw value stored inside a snapshot, removing all inline-snapshot-specific\n wrappers such as those generated by `external()`, `Is()`, or `snapshot()`.\n\n This function is primarily intended for extension authors who need direct access to the value\n of a previously stored snapshot. For standard test assertions, prefer using the snapshot directly.\n\n Args:\n snapshot_value: The snapshot object from which to extract the value.\n\n Returns:\n The unwrapped value contained in the snapshot.\n\n Example:\n ``` python\n from inline_snapshot import external, snapshot, get_snapshot_value\n\n s = snapshot([0, external(\"uuid:e3e70682-c209-4cac-a29f-6fbed82c07cd.json\")])\n\n if record:\n # Store value\n assert s == [0, 5]\n else:\n # Use value from snapshot\n value = get_snapshot_value(s)\n # ... do something with value\n ```\n\n <!-- TODO: Find a way to test this code in the docs -->\n \"\"\"\n if state().active:\n return unwrap(snapshot_value)[0]\n else:\n return snapshot_value\n\n\n# Source: src/inline_snapshot/_external/_outsource.py\ndef outsource(data: Any, suffix: str | None = None, storage: str | None = None) -> Any:\n if suffix and suffix[0] != \".\":\n raise ValueError(\"suffix has to start with a '.' like '.png'\")\n\n if not state().active:\n return data\n\n # check if the suffix/datatype is supported\n get_format_handler(data, suffix or \"\")\n\n return Outsourced(data, suffix, storage)\n\n\n# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 9, "n_files_resolved": 6, "n_chars_extracted": 2499}, "tests/test_hasrepr.py::6": {"resolved_imports": [], "used_names": ["HasRepr"], "enclosing_function": "test_hasrepr_eq", "extracted_code": "", "n_imports_parsed": 1, "n_files_resolved": 0, "n_chars_extracted": 0}, "tests/test_hasrepr.py::12": {"resolved_imports": [], "used_names": ["HasRepr"], "enclosing_function": "test_hasrepr_eq", "extracted_code": "", "n_imports_parsed": 1, "n_files_resolved": 0, "n_chars_extracted": 0}, "tests/test_inline_snapshot.py::21": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": ["pytest", "snapshot", "snapshot_env"], "enclosing_function": "test_snapshot_eq", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)\n\n\n# Source: src/inline_snapshot/_global_state.py\ndef snapshot_env() -> Generator[State]:\n from ._external._storage._hash import HashStorage\n\n old = _current\n\n enter_snapshot_context()\n\n try:\n with TemporaryDirectory() as dir:\n _current.all_storages = dict(old.all_storages)\n _current.all_storages[\"hash\"] = HashStorage(dir)\n\n yield _current\n finally:\n leave_snapshot_context()", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 1109}, "tests/test_inline_snapshot.py::159": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": ["itertools", "pytest"], "enclosing_function": "test_generic_multi", "extracted_code": "", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 0}, "tests/test_inline_snapshot.py::108": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": ["pytest"], "enclosing_function": "test_generic", "extracted_code": "", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 0}, "tests/test_inline_snapshot.py::647": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": ["itertools", "nullcontext", "pytest"], "enclosing_function": "test_type_error", "extracted_code": "", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 0}, "tests/test_inline_snapshot.py::92": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": ["pytest"], "enclosing_function": "test_generic", "extracted_code": "", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 0}, "tests/test_inline_snapshot.py::99": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": ["pytest"], "enclosing_function": "test_generic", "extracted_code": "", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 0}, "tests/test_inline_snapshot.py::109": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": ["pytest"], "enclosing_function": "test_generic", "extracted_code": "", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 0}, "tests/test_inline_snapshot.py::29": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": ["pytest", "snapshot", "snapshot_env"], "enclosing_function": "test_disabled", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)\n\n\n# Source: src/inline_snapshot/_global_state.py\ndef snapshot_env() -> Generator[State]:\n from ._external._storage._hash import HashStorage\n\n old = _current\n\n enter_snapshot_context()\n\n try:\n with TemporaryDirectory() as dir:\n _current.all_storages = dict(old.all_storages)\n _current.all_storages[\"hash\"] = HashStorage(dir)\n\n yield _current\n finally:\n leave_snapshot_context()", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 1109}, "tests/test_inline_snapshot.py::635": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": ["itertools", "nullcontext", "pytest"], "enclosing_function": "test_type_error", "extracted_code": "", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 0}, "tests/test_inline_snapshot.py::20": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": ["pytest", "snapshot", "snapshot_env"], "enclosing_function": "test_snapshot_eq", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)\n\n\n# Source: src/inline_snapshot/_global_state.py\ndef snapshot_env() -> Generator[State]:\n from ._external._storage._hash import HashStorage\n\n old = _current\n\n enter_snapshot_context()\n\n try:\n with TemporaryDirectory() as dir:\n _current.all_storages = dict(old.all_storages)\n _current.all_storages[\"hash\"] = HashStorage(dir)\n\n yield _current\n finally:\n leave_snapshot_context()", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 1109}, "tests/test_inline_snapshot.py::871": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": ["snapshot"], "enclosing_function": "test_trailing_comma", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 670}, "tests/test_inline_snapshot.py::625": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": [], "enclosing_function": "test_unused_snapshot", "extracted_code": "", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 0}, "tests/test_inline_snapshot.py::28": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": ["pytest", "snapshot", "snapshot_env"], "enclosing_function": "test_disabled", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)\n\n\n# Source: src/inline_snapshot/_global_state.py\ndef snapshot_env() -> Generator[State]:\n from ._external._storage._hash import HashStorage\n\n old = _current\n\n enter_snapshot_context()\n\n try:\n with TemporaryDirectory() as dir:\n _current.all_storages = dict(old.all_storages)\n _current.all_storages[\"hash\"] = HashStorage(dir)\n\n yield _current\n finally:\n leave_snapshot_context()", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 1109}, "tests/test_inline_snapshot.py::105": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": ["pytest"], "enclosing_function": "test_generic", "extracted_code": "", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 0}, "tests/test_inline_snapshot.py::817": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": ["snapshot"], "enclosing_function": "test_quoting_change_is_no_update", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 670}, "tests/test_inline_snapshot.py::645": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": ["itertools", "nullcontext", "pytest"], "enclosing_function": "test_type_error", "extracted_code": "", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 0}, "tests/test_inline_snapshot.py::887": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": ["contextlib", "warnings"], "enclosing_function": "warns", "extracted_code": "", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 0}, "tests/test_inline_snapshot.py::587": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": ["Flags"], "enclosing_function": "test_flags_repr", "extracted_code": "# Source: src/inline_snapshot/_flags.py\nclass Flags:\n \"\"\"\n fix: the value needs to be changed to pass the tests\n update: the value should be updated because the token-stream has changed\n create: the snapshot is empty `snapshot()`\n trim: the snapshot contains more values than necessary. 1 could be trimmed in `5 in snapshot([1,5])`.\n \"\"\"\n\n def __init__(self, flags: set[Category] = set()):\n self.create = \"create\" in flags\n self.fix = \"fix\" in flags\n self.fix_assert = \"fix-assert\" in flags\n self.trim = \"trim\" in flags\n self.update = \"update\" in flags\n\n def to_set(self) -> set[Category]:\n return cast(\n Set[Category], {k.replace(\"_\", \"-\") for k, v in self.__dict__.items() if v}\n )\n\n def __iter__(self):\n return (k.replace(\"_\", \"-\") for k, v in self.__dict__.items() if v)\n\n def __repr__(self):\n return f\"Flags({self.to_set()})\"\n\n @staticmethod\n def all() -> Flags:\n return Flags({\"fix\", \"create\", \"update\", \"trim\", \"fix-assert\"})", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 1049}, "tests/test_inline_snapshot.py::790": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_flags.py", "src/inline_snapshot/_global_state.py"], "used_names": ["snapshot"], "enclosing_function": "test_quoting_change_is_no_update", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 12, "n_files_resolved": 3, "n_chars_extracted": 670}, "tests/test_is.py::29": {"resolved_imports": ["src/inline_snapshot/_is.py", "src/inline_snapshot/_inline_snapshot.py"], "used_names": ["Is"], "enclosing_function": "test_is_repr", "extracted_code": "# Source: src/inline_snapshot/_is.py\n T = typing.TypeVar(\"T\")\n\n def Is(v: T) -> T:\n return v\n\nelse:\n\n class IsMetaType(type):\n def __call__(self, value):\n if not state().active:\n return value\n return super().__call__(value)\n\nelse:\n\n class IsMetaType(type):\n def __call__(self, value):\n if not state().active:\n return value\n return super().__call__(value)\n\n @declare_unmanaged\n class Is(metaclass=IsMetaType):\n def __init__(self, value):\n self.value = value\n\n\n @declare_unmanaged\n class Is(metaclass=IsMetaType):\n def __init__(self, value):\n self.value = value\n\n def __eq__(self, other):\n return self.value == other\n\n def __repr__(self):\n return repr(self.value)", "n_imports_parsed": 3, "n_files_resolved": 2, "n_chars_extracted": 852}, "tests/test_preserve_values.py::229": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["itertools", "pytest"], "enclosing_function": "test_generic", "extracted_code": "", "n_imports_parsed": 4, "n_files_resolved": 1, "n_chars_extracted": 0}, "tests/test_preserve_values.py::231": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["itertools", "pytest"], "enclosing_function": "test_generic", "extracted_code": "", "n_imports_parsed": 4, "n_files_resolved": 1, "n_chars_extracted": 0}, "tests/test_preserve_values.py::241": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["itertools", "pytest"], "enclosing_function": "test_generic", "extracted_code": "", "n_imports_parsed": 4, "n_files_resolved": 1, "n_chars_extracted": 0}, "tests/test_preserve_values.py::54": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_fix_dict_remove", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 4, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_preserve_values.py::10": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_fix_list_fix", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 4, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_preserve_values.py::48": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_fix_dict_remove", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 4, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_preserve_values.py::24": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_fix_list_delete", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 4, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_preserve_values.py::32": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_fix_tuple_delete", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 4, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_preserve_values.py::72": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_fix_dict_with_non_literal_keys", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 4, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_preserve_values.py::40": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_fix_dict_change", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 4, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_preserve_values.py::16": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_fix_list_insert", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 4, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_preserve_values.py::62": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_fix_dict_insert", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 4, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_preserve_values.py::83": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["pytest", "snapshot", "sys"], "enclosing_function": "test_no_update_for_dirty_equals", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 4, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_preserve_values.py::103": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_preserve_case_from_original_mr", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 4, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_pytest_plugin.py::525": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["pytest"], "enclosing_function": "test_run_without_pytest", "extracted_code": "", "n_imports_parsed": 6, "n_files_resolved": 1, "n_chars_extracted": 0}, "tests/test_pytest_plugin.py::576": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_empty_sub_snapshot", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_pytest_plugin.py::536": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_pytest_inlinesnapshot_auto", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_pytest_plugin.py::56": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_create", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_pytest_plugin.py::419": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_disabled", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_pytest_plugin.py::197": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_trim", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_pytest_plugin.py::476": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_assertion_error_loop", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_pytest_plugin.py::152": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["is_pytest_compatible", "snapshot"], "enclosing_function": "test_update", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_pytest_plugin.py::492": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_assertion_error_multiple", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_pytest_plugin.py::554": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_pytest_inlinesnapshot_auto", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_pytest_plugin.py::288": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["pytest", "snapshot"], "enclosing_function": "test_disable_option", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_pytest_plugin.py::293": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["pytest", "snapshot"], "enclosing_function": "test_disable_option", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_pytest_plugin.py::439": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_compare", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_pytest_plugin.py::457": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_compare", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_pytest_plugin.py::395": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_black_config", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_pytest_plugin.py::268": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["is_pytest_compatible", "snapshot"], "enclosing_function": "test_multiple", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_pytest_plugin.py::362": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_multiple_report", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_rewrite_code.py::14": {"resolved_imports": ["src/inline_snapshot/_rewrite_code.py"], "used_names": ["SourcePosition", "SourceRange", "end_of", "pytest", "range_of", "start_of"], "enclosing_function": "test_range", "extracted_code": "", "n_imports_parsed": 7, "n_files_resolved": 1, "n_chars_extracted": 0}, "tests/test_rewrite_code.py::16": {"resolved_imports": ["src/inline_snapshot/_rewrite_code.py"], "used_names": ["SourcePosition", "SourceRange", "end_of", "pytest", "range_of", "start_of"], "enclosing_function": "test_range", "extracted_code": "", "n_imports_parsed": 7, "n_files_resolved": 1, "n_chars_extracted": 0}, "tests/test_rewrite_code.py::19": {"resolved_imports": ["src/inline_snapshot/_rewrite_code.py"], "used_names": ["SourcePosition", "SourceRange", "end_of", "pytest", "range_of", "start_of"], "enclosing_function": "test_range", "extracted_code": "", "n_imports_parsed": 7, "n_files_resolved": 1, "n_chars_extracted": 0}, "tests/test_rewrite_code.py::42": {"resolved_imports": ["src/inline_snapshot/_rewrite_code.py"], "used_names": ["ChangeRecorder"], "enclosing_function": "test_rewrite", "extracted_code": "# Source: src/inline_snapshot/_rewrite_code.py\nclass ChangeRecorder:\n\n def __init__(self):\n self._source_files = defaultdict(SourceFile)\n self._changes = []\n\n def get_source(self, filename) -> SourceFile:\n filename = pathlib.Path(filename)\n if filename not in self._source_files:\n self._source_files[filename] = SourceFile(filename)\n\n return self._source_files[filename]\n\n def files(self) -> Iterable[SourceFile]:\n return self._source_files.values()\n\n def new_change(self):\n return Change(self)\n\n def num_fixes(self):\n changes = set()\n for file in self._source_files.values():\n changes.update(change.change_id for change in file.replacements)\n return len(changes)\n\n def fix_all(self):\n for file in self._source_files.values():\n file.rewrite()\n\n def virtual_write(self):\n for file in self._source_files.values():\n file.virtual_write()\n\n def dump(self): # pragma: no cover\n for file in self._source_files.values():\n print(\"file:\", file.filename)\n for change in file.replacements:\n print(\" change:\", change)", "n_imports_parsed": 7, "n_files_resolved": 1, "n_chars_extracted": 1202}, "tests/test_rewrite_code.py::21": {"resolved_imports": ["src/inline_snapshot/_rewrite_code.py"], "used_names": ["SourcePosition", "SourceRange", "end_of", "pytest", "range_of", "start_of"], "enclosing_function": "test_range", "extracted_code": "", "n_imports_parsed": 7, "n_files_resolved": 1, "n_chars_extracted": 0}, "tests/test_rewrite_code.py::45": {"resolved_imports": ["src/inline_snapshot/_rewrite_code.py"], "used_names": ["ChangeRecorder"], "enclosing_function": "test_rewrite", "extracted_code": "# Source: src/inline_snapshot/_rewrite_code.py\nclass ChangeRecorder:\n\n def __init__(self):\n self._source_files = defaultdict(SourceFile)\n self._changes = []\n\n def get_source(self, filename) -> SourceFile:\n filename = pathlib.Path(filename)\n if filename not in self._source_files:\n self._source_files[filename] = SourceFile(filename)\n\n return self._source_files[filename]\n\n def files(self) -> Iterable[SourceFile]:\n return self._source_files.values()\n\n def new_change(self):\n return Change(self)\n\n def num_fixes(self):\n changes = set()\n for file in self._source_files.values():\n changes.update(change.change_id for change in file.replacements)\n return len(changes)\n\n def fix_all(self):\n for file in self._source_files.values():\n file.rewrite()\n\n def virtual_write(self):\n for file in self._source_files.values():\n file.virtual_write()\n\n def dump(self): # pragma: no cover\n for file in self._source_files.values():\n print(\"file:\", file.filename)\n for change in file.replacements:\n print(\" change:\", change)", "n_imports_parsed": 7, "n_files_resolved": 1, "n_chars_extracted": 1202}, "tests/test_string.py::196": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_utils.py"], "used_names": ["ast", "given", "text", "triple_quote"], "enclosing_function": "test_string_convert", "extracted_code": "# Source: src/inline_snapshot/_utils.py\ndef triple_quote(string):\n \"\"\"Write string literal value with a best effort attempt to avoid\n backslashes.\"\"\"\n string, quote_types = _str_literal_helper(string, quote_types=['\"\"\"', \"'''\"])\n quote_type = quote_types[0]\n\n string = string.replace(\" \\n\", \" \\\\n\\\\\\n\")\n\n string = \"\\\\\\n\" + string\n\n if not string.endswith(\"\\n\"):\n string = string + \"\\\\\\n\"\n\n return f\"{quote_type}{string}{quote_type}\"", "n_imports_parsed": 6, "n_files_resolved": 2, "n_chars_extracted": 463}, "tests/test_string.py::149": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_utils.py"], "used_names": ["snapshot"], "enclosing_function": "test_string_quote_choice", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 2, "n_chars_extracted": 670}, "tests/test_string.py::180": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_utils.py"], "used_names": ["snapshot"], "enclosing_function": "test_string_quote_choice", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 2, "n_chars_extracted": 670}, "tests/test_string.py::152": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_utils.py"], "used_names": ["snapshot"], "enclosing_function": "test_string_quote_choice", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 2, "n_chars_extracted": 670}, "tests/test_string.py::14": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_utils.py"], "used_names": ["snapshot"], "enclosing_function": "test_string_update", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 2, "n_chars_extracted": 670}, "tests/test_string.py::77": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_utils.py"], "used_names": ["snapshot"], "enclosing_function": "test_string_newline", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 2, "n_chars_extracted": 670}, "tests/test_string.py::21": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_utils.py"], "used_names": ["snapshot"], "enclosing_function": "test_string_update", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 2, "n_chars_extracted": 670}, "tests/test_string.py::39": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_utils.py"], "used_names": ["snapshot"], "enclosing_function": "test_string_update", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 2, "n_chars_extracted": 670}, "tests/test_string.py::171": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_utils.py"], "used_names": ["snapshot"], "enclosing_function": "test_string_quote_choice", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 2, "n_chars_extracted": 670}, "tests/test_string.py::79": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_utils.py"], "used_names": ["snapshot"], "enclosing_function": "test_string_newline", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 2, "n_chars_extracted": 670}, "tests/test_string.py::88": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_utils.py"], "used_names": ["snapshot"], "enclosing_function": "test_string_newline", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 2, "n_chars_extracted": 670}, "tests/test_string.py::48": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_utils.py"], "used_names": ["snapshot"], "enclosing_function": "test_string_newline", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 2, "n_chars_extracted": 670}, "tests/test_string.py::106": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_utils.py"], "used_names": ["snapshot"], "enclosing_function": "test_string_newline", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 2, "n_chars_extracted": 670}, "tests/test_string.py::28": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_utils.py"], "used_names": ["snapshot"], "enclosing_function": "test_string_update", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 6, "n_files_resolved": 2, "n_chars_extracted": 670}, "tests/test_typing.py::28": {"resolved_imports": [], "used_names": ["sys"], "enclosing_function": "f", "extracted_code": "", "n_imports_parsed": 2, "n_files_resolved": 0, "n_chars_extracted": 0}, "tests/test_xdist.py::21": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_xdist", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 2, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_xdist.py::62": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_xdist_and_disable", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 2, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_xdist.py::58": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_xdist_and_disable", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 2, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_xdist.py::60": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_xdist_and_disable", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 2, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_xdist.py::17": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_xdist", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 2, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/test_xdist.py::110": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["snapshot"], "enclosing_function": "test_xdist_zero_processes", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 2, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/external/test_external.py::334": {"resolved_imports": ["src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_external/_external_location.py", "src/inline_snapshot/_external/_find_external.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py"], "used_names": ["snapshot"], "enclosing_function": "test_pytest_trim_external", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 13, "n_files_resolved": 7, "n_chars_extracted": 670}, "tests/external/test_external.py::359": {"resolved_imports": ["src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_external/_external_location.py", "src/inline_snapshot/_external/_find_external.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py"], "used_names": ["snapshot"], "enclosing_function": "test_pytest_new_external", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 13, "n_files_resolved": 7, "n_chars_extracted": 670}, "tests/external/test_external.py::391": {"resolved_imports": ["src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_external/_external_location.py", "src/inline_snapshot/_external/_find_external.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py"], "used_names": ["snapshot"], "enclosing_function": "test_pytest_config_hash_length", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 13, "n_files_resolved": 7, "n_chars_extracted": 670}, "tests/external/test_external.py::76": {"resolved_imports": ["src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_external/_external_location.py", "src/inline_snapshot/_external/_find_external.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py"], "used_names": ["outsource", "snapshot_env"], "enclosing_function": "test_compare_outsource", "extracted_code": "# Source: src/inline_snapshot/_external/_outsource.py\ndef outsource(data: Any, suffix: str | None = None, storage: str | None = None) -> Any:\n if suffix and suffix[0] != \".\":\n raise ValueError(\"suffix has to start with a '.' like '.png'\")\n\n if not state().active:\n return data\n\n # check if the suffix/datatype is supported\n get_format_handler(data, suffix or \"\")\n\n return Outsourced(data, suffix, storage)\n\n\n# Source: src/inline_snapshot/_global_state.py\ndef snapshot_env() -> Generator[State]:\n from ._external._storage._hash import HashStorage\n\n old = _current\n\n enter_snapshot_context()\n\n try:\n with TemporaryDirectory() as dir:\n _current.all_storages = dict(old.all_storages)\n _current.all_storages[\"hash\"] = HashStorage(dir)\n\n yield _current\n finally:\n leave_snapshot_context()", "n_imports_parsed": 13, "n_files_resolved": 7, "n_chars_extracted": 873}, "tests/external/test_external.py::77": {"resolved_imports": ["src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_external/_external_location.py", "src/inline_snapshot/_external/_find_external.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py"], "used_names": ["outsource", "snapshot_env"], "enclosing_function": "test_compare_outsource", "extracted_code": "# Source: src/inline_snapshot/_external/_outsource.py\ndef outsource(data: Any, suffix: str | None = None, storage: str | None = None) -> Any:\n if suffix and suffix[0] != \".\":\n raise ValueError(\"suffix has to start with a '.' like '.png'\")\n\n if not state().active:\n return data\n\n # check if the suffix/datatype is supported\n get_format_handler(data, suffix or \"\")\n\n return Outsourced(data, suffix, storage)\n\n\n# Source: src/inline_snapshot/_global_state.py\ndef snapshot_env() -> Generator[State]:\n from ._external._storage._hash import HashStorage\n\n old = _current\n\n enter_snapshot_context()\n\n try:\n with TemporaryDirectory() as dir:\n _current.all_storages = dict(old.all_storages)\n _current.all_storages[\"hash\"] = HashStorage(dir)\n\n yield _current\n finally:\n leave_snapshot_context()", "n_imports_parsed": 13, "n_files_resolved": 7, "n_chars_extracted": 873}, "tests/external/test_external.py::139": {"resolved_imports": ["src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_external/_external_location.py", "src/inline_snapshot/_external/_find_external.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py"], "used_names": ["external", "outsource", "raises", "snapshot", "snapshot_env"], "enclosing_function": "test_hash_not_found", "extracted_code": "# Source: src/inline_snapshot/_external/_external.py\ndef external(name: str | None = None):\n return create_snapshot(External, name)\n\n\n# Source: src/inline_snapshot/_external/_outsource.py\ndef outsource(data: Any, suffix: str | None = None, storage: str | None = None) -> Any:\n if suffix and suffix[0] != \".\":\n raise ValueError(\"suffix has to start with a '.' like '.png'\")\n\n if not state().active:\n return data\n\n # check if the suffix/datatype is supported\n get_format_handler(data, suffix or \"\")\n\n return Outsourced(data, suffix, storage)\n\n\n# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)\n\n\n# Source: src/inline_snapshot/_global_state.py\ndef snapshot_env() -> Generator[State]:\n from ._external._storage._hash import HashStorage\n\n old = _current\n\n enter_snapshot_context()\n\n try:\n with TemporaryDirectory() as dir:\n _current.all_storages = dict(old.all_storages)\n _current.all_storages[\"hash\"] = HashStorage(dir)\n\n yield _current\n finally:\n leave_snapshot_context()\n\n\n# Source: src/inline_snapshot/extra.py\ndef raises(exception: Snapshot[str]):\n \"\"\"Check that an exception is raised.\n\n Parameters:\n exception: Snapshot that is compared with `#!python f\"{type}: {message}\"` if an exception occurs, or `#!python \"<no exception>\"` if no exception is 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 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(snapshot(\"ZeroDivisionError: division by zero\")):\n 1 / 0\n ```\n \"\"\"\n\n try:\n yield\n except BaseException 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_imports_parsed": 13, "n_files_resolved": 7, "n_chars_extracted": 2976}, "tests/external/test_external.py::522": {"resolved_imports": ["src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_external/_external_location.py", "src/inline_snapshot/_external/_find_external.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py"], "used_names": ["apply_changes", "ensure_import", "snapshot"], "enclosing_function": "test_ensure_imports_with_comment", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)\n\n\n# Source: src/inline_snapshot/_external/_find_external.py\ndef ensure_import(\n filename,\n imports: Dict[str, Set[str]],\n module_imports: Set[str],\n recorder: ChangeRecorder,\n):\n source = Source.for_filename(filename)\n\n change = recorder.new_change()\n\n tree = source.tree\n token = source.asttokens()\n\n my_module_name = module_name_of(filename)\n\n code = \"\"\n for module, names in imports.items():\n if module == my_module_name:\n continue\n if module == \"builtins\":\n continue\n for name in sorted(names):\n if not contains_import(tree, module, name):\n code += f\"from {module} import {name}\\n\"\n\n for module in sorted(module_imports):\n if not contains_module_import(tree, module):\n code += f\"import {module}\\n\"\n\n assert isinstance(tree, ast.Module)\n\n # find source position\n last_import = None\n for node in tree.body:\n if not (\n isinstance(node, (ast.ImportFrom, ast.Import))\n or (\n isinstance(node, ast.Expr)\n and isinstance(node.value, ast.Constant)\n and isinstance(node.value.value, str)\n )\n ):\n break\n last_import = node\n\n if last_import is None:\n position = start_of(tree.body[0].first_token) # type: ignore\n else:\n last_token = last_import.last_token # type: ignore\n while True:\n next_token = token.next_token(last_token)\n if last_token.end[0] == next_token.end[0]:\n last_token = next_token\n else:\n break\n position = end_of(last_token)\n\n if code:\n code = \"\\n\" + code\n change.insert(position, code, filename=filename)", "n_imports_parsed": 13, "n_files_resolved": 7, "n_chars_extracted": 2445}, "tests/external/test_external.py::338": {"resolved_imports": ["src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_external/_external_location.py", "src/inline_snapshot/_external/_find_external.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py"], "used_names": ["snapshot"], "enclosing_function": "test_pytest_trim_external", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 13, "n_files_resolved": 7, "n_chars_extracted": 670}, "tests/external/test_external.py::574": {"resolved_imports": ["src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_external/_external_location.py", "src/inline_snapshot/_external/_find_external.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py"], "used_names": ["snapshot"], "enclosing_function": "test_new_externals", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 13, "n_files_resolved": 7, "n_chars_extracted": 670}, "tests/external/test_external.py::501": {"resolved_imports": ["src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_external/_external_location.py", "src/inline_snapshot/_external/_find_external.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py"], "used_names": ["apply_changes", "ensure_import", "snapshot"], "enclosing_function": "test_ensure_imports", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)\n\n\n# Source: src/inline_snapshot/_external/_find_external.py\ndef ensure_import(\n filename,\n imports: Dict[str, Set[str]],\n module_imports: Set[str],\n recorder: ChangeRecorder,\n):\n source = Source.for_filename(filename)\n\n change = recorder.new_change()\n\n tree = source.tree\n token = source.asttokens()\n\n my_module_name = module_name_of(filename)\n\n code = \"\"\n for module, names in imports.items():\n if module == my_module_name:\n continue\n if module == \"builtins\":\n continue\n for name in sorted(names):\n if not contains_import(tree, module, name):\n code += f\"from {module} import {name}\\n\"\n\n for module in sorted(module_imports):\n if not contains_module_import(tree, module):\n code += f\"import {module}\\n\"\n\n assert isinstance(tree, ast.Module)\n\n # find source position\n last_import = None\n for node in tree.body:\n if not (\n isinstance(node, (ast.ImportFrom, ast.Import))\n or (\n isinstance(node, ast.Expr)\n and isinstance(node.value, ast.Constant)\n and isinstance(node.value.value, str)\n )\n ):\n break\n last_import = node\n\n if last_import is None:\n position = start_of(tree.body[0].first_token) # type: ignore\n else:\n last_token = last_import.last_token # type: ignore\n while True:\n next_token = token.next_token(last_token)\n if last_token.end[0] == next_token.end[0]:\n last_token = next_token\n else:\n break\n position = end_of(last_token)\n\n if code:\n code = \"\\n\" + code\n change.insert(position, code, filename=filename)", "n_imports_parsed": 13, "n_files_resolved": 7, "n_chars_extracted": 2445}, "tests/external/test_external.py::543": {"resolved_imports": ["src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_external/_external_location.py", "src/inline_snapshot/_external/_find_external.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py"], "used_names": ["apply_changes", "ensure_import", "snapshot"], "enclosing_function": "test_ensure_imports_with_docstring", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)\n\n\n# Source: src/inline_snapshot/_external/_find_external.py\ndef ensure_import(\n filename,\n imports: Dict[str, Set[str]],\n module_imports: Set[str],\n recorder: ChangeRecorder,\n):\n source = Source.for_filename(filename)\n\n change = recorder.new_change()\n\n tree = source.tree\n token = source.asttokens()\n\n my_module_name = module_name_of(filename)\n\n code = \"\"\n for module, names in imports.items():\n if module == my_module_name:\n continue\n if module == \"builtins\":\n continue\n for name in sorted(names):\n if not contains_import(tree, module, name):\n code += f\"from {module} import {name}\\n\"\n\n for module in sorted(module_imports):\n if not contains_module_import(tree, module):\n code += f\"import {module}\\n\"\n\n assert isinstance(tree, ast.Module)\n\n # find source position\n last_import = None\n for node in tree.body:\n if not (\n isinstance(node, (ast.ImportFrom, ast.Import))\n or (\n isinstance(node, ast.Expr)\n and isinstance(node.value, ast.Constant)\n and isinstance(node.value.value, str)\n )\n ):\n break\n last_import = node\n\n if last_import is None:\n position = start_of(tree.body[0].first_token) # type: ignore\n else:\n last_token = last_import.last_token # type: ignore\n while True:\n next_token = token.next_token(last_token)\n if last_token.end[0] == next_token.end[0]:\n last_token = next_token\n else:\n break\n position = end_of(last_token)\n\n if code:\n code = \"\\n\" + code\n change.insert(position, code, filename=filename)", "n_imports_parsed": 13, "n_files_resolved": 7, "n_chars_extracted": 2445}, "tests/external/test_external.py::19": {"resolved_imports": ["src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_external/_external_location.py", "src/inline_snapshot/_external/_find_external.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py"], "used_names": ["snapshot"], "enclosing_function": "test_basic", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 13, "n_files_resolved": 7, "n_chars_extracted": 670}, "tests/external/test_external.py::434": {"resolved_imports": ["src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_external/_external_location.py", "src/inline_snapshot/_external/_find_external.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py"], "used_names": ["ExternalLocation", "Path", "ast", "snapshot", "used_externals_in"], "enclosing_function": "test_uses_external", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)\n\n\n# Source: src/inline_snapshot/_external/_external_location.py\nclass ExternalLocation(Location):\n storage: str\n stem: str\n suffix: str\n\n filename: Path | None = None\n qualname: str | None = None\n linenumber: int | None = None\n\n @classmethod\n def from_name(\n cls,\n name: str | None,\n *,\n context: AdapterContext | None = None,\n filename: Path | None = None,\n ):\n from inline_snapshot._global_state import state\n\n if not name:\n storage = state().config.default_storage\n stem = \"\"\n suffix = \"\"\n else:\n m = re.fullmatch(r\"([0-9a-fA-F]{64}|[0-9a-fA-F]+\\*)(\\.[a-zA-Z0-9]+)\", name)\n\n if m:\n storage = \"hash\"\n path = name\n elif \":\" in name:\n storage, path = name.split(\":\", 1)\n if storage not in (\"hash\", \"uuid\"):\n raise ValueError(f\"storage has to be hash or uuid\")\n else:\n storage = state().config.default_storage\n path = name\n\n if \".\" in path:\n stem, suffix = path.split(\".\", 1)\n suffix = \".\" + suffix\n elif not path:\n stem = \"\"\n suffix = \"\"\n else:\n raise ValueError(f\"'{name}' is missing a suffix\")\n\n qualname = None\n if context:\n filename = Path(context.file.filename)\n qualname = context.qualname\n\n return cls(storage, stem, suffix, filename, qualname, None)\n\n @property\n def path(self) -> str:\n return f\"{self.stem or ''}{self.suffix or ''}\"\n\n def to_str(self):\n return str(self)\n\n def __str__(self) -> str:\n return f\"{self.storage}:{self.path}\"\n\n def with_stem(self, new_stem):\n return dataclasses.replace(self, stem=new_stem)\n\n @contextmanager\n def load(self) -> Generator[Path]:\n from inline_snapshot._global_state import state\n\n assert self.storage\n\n storage = state().all_storages[self.storage]\n with storage.load(self) as file:\n yield file\n\n def store(self, new_file: Path):\n from inline_snapshot._global_state import state\n\n assert self.storage\n\n storage = state().all_storages[self.storage]\n storage.store(self, new_file)\n\n def delete(self):\n from inline_snapshot._global_state import state\n\n assert self.storage\n\n storage = state().all_storages[self.storage]\n storage.delete(self)\n\n def exists(self):\n return self.stem", "n_imports_parsed": 13, "n_files_resolved": 7, "n_chars_extracted": 3278}, "tests/external/test_external.py::213": {"resolved_imports": ["src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_external/_external_location.py", "src/inline_snapshot/_external/_find_external.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py"], "used_names": ["snapshot"], "enclosing_function": "test_pytest_compare_external", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 13, "n_files_resolved": 7, "n_chars_extracted": 670}, "tests/external/test_external.py::401": {"resolved_imports": ["src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_external/_external_location.py", "src/inline_snapshot/_external/_find_external.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py"], "used_names": ["snapshot"], "enclosing_function": "test_pytest_config_hash_length", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 13, "n_files_resolved": 7, "n_chars_extracted": 670}, "tests/external/test_external.py::302": {"resolved_imports": ["src/inline_snapshot/_external/_external.py", "src/inline_snapshot/_external/_outsource.py", "src/inline_snapshot/_inline_snapshot.py", "src/inline_snapshot/_external/_external_location.py", "src/inline_snapshot/_external/_find_external.py", "src/inline_snapshot/_global_state.py", "src/inline_snapshot/extra.py"], "used_names": ["snapshot"], "enclosing_function": "test_pytest_trim_external", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 13, "n_files_resolved": 7, "n_chars_extracted": 670}, "tests/external/test_external_file.py::94": {"resolved_imports": ["src/inline_snapshot/_inline_snapshot.py"], "used_names": ["Example", "snapshot"], "enclosing_function": "test_external_in_other_dir", "extracted_code": "# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 2, "n_files_resolved": 1, "n_chars_extracted": 670}, "tests/external/test_external_location.py::36": {"resolved_imports": ["src/inline_snapshot/_external/_external_location.py", "src/inline_snapshot/_inline_snapshot.py"], "used_names": ["ExternalLocation", "snapshot"], "enclosing_function": "test_external_location", "extracted_code": "# Source: src/inline_snapshot/_external/_external_location.py\nclass ExternalLocation(Location):\n storage: str\n stem: str\n suffix: str\n\n filename: Path | None = None\n qualname: str | None = None\n linenumber: int | None = None\n\n @classmethod\n def from_name(\n cls,\n name: str | None,\n *,\n context: AdapterContext | None = None,\n filename: Path | None = None,\n ):\n from inline_snapshot._global_state import state\n\n if not name:\n storage = state().config.default_storage\n stem = \"\"\n suffix = \"\"\n else:\n m = re.fullmatch(r\"([0-9a-fA-F]{64}|[0-9a-fA-F]+\\*)(\\.[a-zA-Z0-9]+)\", name)\n\n if m:\n storage = \"hash\"\n path = name\n elif \":\" in name:\n storage, path = name.split(\":\", 1)\n if storage not in (\"hash\", \"uuid\"):\n raise ValueError(f\"storage has to be hash or uuid\")\n else:\n storage = state().config.default_storage\n path = name\n\n if \".\" in path:\n stem, suffix = path.split(\".\", 1)\n suffix = \".\" + suffix\n elif not path:\n stem = \"\"\n suffix = \"\"\n else:\n raise ValueError(f\"'{name}' is missing a suffix\")\n\n qualname = None\n if context:\n filename = Path(context.file.filename)\n qualname = context.qualname\n\n return cls(storage, stem, suffix, filename, qualname, None)\n\n @property\n def path(self) -> str:\n return f\"{self.stem or ''}{self.suffix or ''}\"\n\n def to_str(self):\n return str(self)\n\n def __str__(self) -> str:\n return f\"{self.storage}:{self.path}\"\n\n def with_stem(self, new_stem):\n return dataclasses.replace(self, stem=new_stem)\n\n @contextmanager\n def load(self) -> Generator[Path]:\n from inline_snapshot._global_state import state\n\n assert self.storage\n\n storage = state().all_storages[self.storage]\n with storage.load(self) as file:\n yield file\n\n def store(self, new_file: Path):\n from inline_snapshot._global_state import state\n\n assert self.storage\n\n storage = state().all_storages[self.storage]\n storage.store(self, new_file)\n\n def delete(self):\n from inline_snapshot._global_state import state\n\n assert self.storage\n\n storage = state().all_storages[self.storage]\n storage.delete(self)\n\n def exists(self):\n return self.stem\n\n\n# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 3, "n_files_resolved": 2, "n_chars_extracted": 3278}, "tests/external/test_external_location.py::38": {"resolved_imports": ["src/inline_snapshot/_external/_external_location.py", "src/inline_snapshot/_inline_snapshot.py"], "used_names": ["ExternalLocation", "snapshot"], "enclosing_function": "test_external_location", "extracted_code": "# Source: src/inline_snapshot/_external/_external_location.py\nclass ExternalLocation(Location):\n storage: str\n stem: str\n suffix: str\n\n filename: Path | None = None\n qualname: str | None = None\n linenumber: int | None = None\n\n @classmethod\n def from_name(\n cls,\n name: str | None,\n *,\n context: AdapterContext | None = None,\n filename: Path | None = None,\n ):\n from inline_snapshot._global_state import state\n\n if not name:\n storage = state().config.default_storage\n stem = \"\"\n suffix = \"\"\n else:\n m = re.fullmatch(r\"([0-9a-fA-F]{64}|[0-9a-fA-F]+\\*)(\\.[a-zA-Z0-9]+)\", name)\n\n if m:\n storage = \"hash\"\n path = name\n elif \":\" in name:\n storage, path = name.split(\":\", 1)\n if storage not in (\"hash\", \"uuid\"):\n raise ValueError(f\"storage has to be hash or uuid\")\n else:\n storage = state().config.default_storage\n path = name\n\n if \".\" in path:\n stem, suffix = path.split(\".\", 1)\n suffix = \".\" + suffix\n elif not path:\n stem = \"\"\n suffix = \"\"\n else:\n raise ValueError(f\"'{name}' is missing a suffix\")\n\n qualname = None\n if context:\n filename = Path(context.file.filename)\n qualname = context.qualname\n\n return cls(storage, stem, suffix, filename, qualname, None)\n\n @property\n def path(self) -> str:\n return f\"{self.stem or ''}{self.suffix or ''}\"\n\n def to_str(self):\n return str(self)\n\n def __str__(self) -> str:\n return f\"{self.storage}:{self.path}\"\n\n def with_stem(self, new_stem):\n return dataclasses.replace(self, stem=new_stem)\n\n @contextmanager\n def load(self) -> Generator[Path]:\n from inline_snapshot._global_state import state\n\n assert self.storage\n\n storage = state().all_storages[self.storage]\n with storage.load(self) as file:\n yield file\n\n def store(self, new_file: Path):\n from inline_snapshot._global_state import state\n\n assert self.storage\n\n storage = state().all_storages[self.storage]\n storage.store(self, new_file)\n\n def delete(self):\n from inline_snapshot._global_state import state\n\n assert self.storage\n\n storage = state().all_storages[self.storage]\n storage.delete(self)\n\n def exists(self):\n return self.stem\n\n\n# Source: src/inline_snapshot/_inline_snapshot.py\ndef snapshot(obj: Any = undefined) -> Any:\n \"\"\"`snapshot()` is a placeholder for some value.\n\n `pytest --inline-snapshot=create` will create the value which matches your conditions.\n\n >>> assert 5 == snapshot()\n >>> assert 5 <= snapshot()\n >>> assert 5 >= snapshot()\n >>> assert 5 in snapshot()\n\n `snapshot()[key]` can be used to create sub-snapshots.\n\n The generated value will be inserted as argument to `snapshot()`\n\n >>> assert 5 == snapshot(5)\n\n `snapshot(value)` has general the semantic of an noop which returns `value`.\n \"\"\"\n\n return create_snapshot(SnapshotReference, obj, 1)", "n_imports_parsed": 3, "n_files_resolved": 2, "n_chars_extracted": 3278}}} |