Skip to content

BinaryGenerator generator

Generate synthetic bytes, optionally with MIME-sniffable signature bytes.

Why: Use BinaryGenerator for bounded binary payload fixtures, optionally with a recognisable MIME signature; use a file source when realistic document contents matter.

Category: core.

Output: bytes.

1
<key name="value" generator="BinaryGenerator(min_len=128, max_len=256, mime_type='image/png')"/>

Parameters

  • min_len: int | None; Default None — Inclusive minimum payload size in bytes.
  • max_len: int | None; Default None — Inclusive maximum payload size in bytes.
  • mime_type: str | None; Default None — Optional MIME type whose signature bytes prefix the generated payload.