Skip to content

Commit

Permalink
fix: preserve Falsy values in assertion diff function (#789)
Browse files Browse the repository at this point in the history
  • Loading branch information
atharva-2001 authored Aug 17, 2023
1 parent 80fcf8f commit 118ef92
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/syrupy/assertion.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ def get_assert_diff(self) -> List[str]:
# Rotate to place exception with message at first line
return lines[-1:] + lines[:-1]
snapshot_data = assertion_result.recalled_data
serialized_data = assertion_result.asserted_data or ""
serialized_data = (
assertion_result.asserted_data
if assertion_result.asserted_data is not None
else ""
)
diff: List[str] = []
if snapshot_data is None:
diff.append(
Expand All @@ -215,7 +219,8 @@ def get_assert_diff(self) -> List[str]:
)
)
if not assertion_result.success:
diff.extend(self.extension.diff_lines(serialized_data, snapshot_data or ""))
snapshot_data = snapshot_data if snapshot_data is not None else ""
diff.extend(self.extension.diff_lines(serialized_data, snapshot_data))
return diff

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

0 comments on commit 118ef92

Please sign in to comment.