-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Labels
bugSomething isn't workingSomething isn't workingdocumentationImprovements or additions to documentationImprovements or additions to documentation
Milestone
Description
Describe the bug
SingleFileSnapshotExtension
crashes when trying to serialize a Dict with a number value.
To reproduce
run pytest --snapshot-update
on a file containing the below test:
from syrupy.extensions.single_file import SingleFileSnapshotExtension
from syrupy.extensions.amber import AmberSnapshotExtension
def test_foo(snapshot):
value = {"x": 0}
# this works:
assert value == snapshot(extension_class=AmberSnapshotExtension)
#this does not:
assert value == snapshot(extension_class=SingleFileSnapshotExtension)
Expected behavior
The test should generate a snapshot file without errors.
Screenshots
> assert value == snapshot(extension_class=SingleFileSnapshotExtension)
E assert [+ received] == [- snapshot]
E TypeError: 'str' object cannot be interpreted as an integer
E Traceback (most recent call last):
E File ".../site-packages/syrupy/assertion.py", line 268, in _assert
E serialized_data = self._serialize(data)
E ^^^^^^^^^^^^^^^^^^^^^
E File ".../site-packages/syrupy/assertion.py", line 181, in _serialize
E return self.extension.serialize(
E ^^^^^^^^^^^^^^^^^^^^^^^^^
E File ".../site-packages/syrupy/extensions/single_file.py", line 52, in serialize
E return self.get_supported_dataclass()(data)
E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test_x.py:24: AssertionError
Environment (please complete the following information):
- OS: macOS 13.5
- Syrupy Version: 4.0.2
- Python Version: CPython 3.11.3
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingdocumentationImprovements or additions to documentationImprovements or additions to documentation
Type
Projects
Status
Done