Attachments
Attach files and data to test reports during execution.
You can attach files or data to test reports during execution.
TofuPilot automatically stores attachments with test results and uploads them to your Dashboard when configured.
File
You can use attach.file() to attach an existing file from the filesystem.
def test_device(attach, camera):
photo_path = camera.take_photo()
attach.file(photo_path) You can rename the attachment by providing a second parameter.
def test_device(attach, camera):
photo_path = camera.take_photo()
attach.file(photo_path, "device_photo.jpg") Data
You can use attach.data() to attach binary data directly without writing to disk first.
import json
def test_device(attach, device):
diagnostics = device.run_diagnostics()
data = json.dumps(diagnostics, indent=2).encode()
attach.data(data, "diagnostics.json") How is this guide?