Skip to content

Commit 118ef92

Browse files
authored
fix: preserve Falsy values in assertion diff function (#789)
1 parent 80fcf8f commit 118ef92

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/syrupy/assertion.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,11 @@ def get_assert_diff(self) -> List[str]:
206206
# Rotate to place exception with message at first line
207207
return lines[-1:] + lines[:-1]
208208
snapshot_data = assertion_result.recalled_data
209-
serialized_data = assertion_result.asserted_data or ""
209+
serialized_data = (
210+
assertion_result.asserted_data
211+
if assertion_result.asserted_data is not None
212+
else ""
213+
)
210214
diff: List[str] = []
211215
if snapshot_data is None:
212216
diff.append(
@@ -215,7 +219,8 @@ def get_assert_diff(self) -> List[str]:
215219
)
216220
)
217221
if not assertion_result.success:
218-
diff.extend(self.extension.diff_lines(serialized_data, snapshot_data or ""))
222+
snapshot_data = snapshot_data if snapshot_data is not None else ""
223+
diff.extend(self.extension.diff_lines(serialized_data, snapshot_data))
219224
return diff
220225

221226
def __with_prop(self, prop_name: str, prop_value: Any) -> None:

0 commit comments

Comments
 (0)