Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: preserve Falsy values in assertion diff function #789

Merged
merged 3 commits into from
Aug 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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