Don't try to create sha256 sums for test attachments without files.

Review Request #14887 — Created March 7, 2026 and submitted

Information

Review Board
release-7.1.x

Reviewers

TestCase.create_file_attachment has a has_file argument that allows
creating the attachment without an actual file object (not previously in
the direct signature, but inherited from create_file_attachment_base).
Actually using that would cause a crash when attempting to populate the
sha256 checksum.

This change explicitly lists that argument in the signature and then
uses it to guard against trying to populate the sha256.

Ran unit tests in an extension that used
create_file_attachment(has_file=False) and saw that it no longer
failed.

Summary ID
Don't try to create sha256 sums for test attachments without files.
`TestCase.create_file_attachment` has a `has_file` argument that allows creating the attachment without an actual file object (not previously in the direct signature, but inherited from `create_file_attachment_base`). Actually using that would cause a crash when attempting to populate the sha256 checksum. This change explicitly lists that argument in the signature and then uses it to guard against trying to populate the sha256. Testing Done: Ran unit tests in an extension that used `create_file_attachment(has_file=False)` and saw that it no longer failed.
wnxpmxrqullvpoxuzxryqzkokmzoonmk
maubin
  1. Ship It!
  2. 
      
david
Review request changed
Status:
Completed
Change Summary:
Pushed to release-7.1.x (d4a9e6b)