Skip to content

Simple generators

BinaryGenerator

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.

BooleanGenerator

Generate a boolean with a configurable probability of returning true.

Why: Use BooleanGenerator for binary business states with a known prevalence, such as active or consented; use a constant when every row must have the same state.

Category: core.

Output: bool.

1
<key name="value" generator="BooleanGenerator(prob_true=0.8)"/>

Parameters

  • prob_true: float; Default 0.5 β€” Probability from 0.0 to 1.0 that a row evaluates to true.

ColorGenerator

Generate color values in different formats.

Why: Use ColorGenerator for UI, catalogue, or theme fixtures that need syntactically valid color values; use a constant when brand colors are fixed requirements.

Category: core.

Output: str.

1
<key name="value" generator="ColorGenerator(format_type='hex')"/>

Parameters

  • format_type: str; Default hex β€” Output representation: hexadecimal, RGB, or named color.

FloatGenerator

Generate floating-point values within a configurable range and distribution.

Why: Use FloatGenerator for bounded measurements, ratios, or monetary test values that require decimal granularity; use IntegerGenerator when fractional values are invalid.

Category: core.

Output: float.

1
<key name="value" generator="FloatGenerator(min=0.0, max=100.0, granularity=0.01, distribution='uniform')"/>

Parameters

  • min: float | null; Default None β€” Inclusive lower bound of generated values.
  • max: float | null; Default None β€” Inclusive upper bound of generated values.
  • granularity: float | null; Default None β€” Smallest permitted step between generated values.
  • distribution: str | null; Default None β€” Statistical distribution used across the bounded numeric grid.

HashGenerator

Generate cryptographic hashes using various algorithms.

Why: Use HashGenerator for new random digest-shaped values such as synthetic fingerprints; use the Hash converter to pseudonymize an existing source value reproducibly.

Category: core.

Output: str.

1
<key name="value" generator="HashGenerator(algorithm='sha256')"/>

Parameters

  • algorithm: str; Default sha256 β€” Supported cryptographic digest algorithm used for the random input.

IncrementGenerator

Generate a sequential integer as a pure function of the row position.

Why: Use IncrementGenerator for row-position-derived local sequences whose result must be worker-invariant; use SequenceTableGenerator when a database must coordinate identifiers across runs.

Category: core.

Output: int.

1
<key name="value" generator="IncrementGenerator(start=1000, end=9999, step=1, include_end=True)"/>

Parameters

  • start: int; Default 1 β€” Value produced for the first row.
  • end: int; Default 9223372036854775807 β€” Upper sequence boundary used to detect exhaustion.
  • step: int; Default 1 β€” Signed increment applied for each following row position.
  • include_end: bool; Default True β€” Whether the exact end boundary is a valid output.

IntegerGenerator

Generate integer values within a configurable range, granularity, and distribution.

Why: Use IntegerGenerator for bounded counts, scores, and ordinal fixtures with optional granularity and distribution; use IncrementGenerator when values must follow row order.

Category: core.

Output: int.

1
<key name="value" generator="IntegerGenerator(min=1, max=100, granularity=5, distribution='uniform')"/>

Parameters

  • min: int | null; Default None β€” Inclusive lower bound of generated integers.
  • max: int | null; Default None β€” Inclusive upper bound of generated integers.
  • granularity: int | null; Default None β€” Positive step defining the permitted integer grid.
  • distribution: str | null; Default None β€” Statistical distribution used across the bounded grid.

NumericStringGenerator

Generate a numeric string using a deterministic RNG.

Why: Use NumericStringGenerator for fixed- or variable-width digit strings where leading zeroes must be retained; use IntegerGenerator when numeric arithmetic and ordering matter.

Category: core.

Output: str.

1
<key name="value" generator="NumericStringGenerator(length=8, char_set='0123456789')"/>

Parameters

  • length: int | null; Default None β€” Fixed output length; mutually exclusive with min_len and max_len.
  • min_len: int | null; Default None β€” Inclusive minimum output length when length is omitted.
  • max_len: int | null; Default None β€” Inclusive maximum output length when length is omitted.
  • char_set: str | null; Default None β€” Non-empty characters sampled for each output position.

PrefixedIdGenerator

Generate an ID composed of a prefix and a regex-defined body.

Why: Use PrefixedIdGenerator for deterministic identifiers with a fixed business prefix and patterned body.

Category: core.

Output: str.

1
<key name="value" generator="PrefixedIdGenerator(prefix='ORD', body_pattern='[A-Z0-9]{8}')"/>

Parameters

  • prefix: str; Default required β€” Fixed business prefix placed before the generated body.
  • body_pattern: str; Default required β€” Regular-expression pattern defining the identifier body.
  • separator: str; Default - β€” Constant text inserted between prefix and body.

StringGenerator

Generate strings with configurable length, character set, uniqueness, prefix, and suffix.

Why: Use StringGenerator for bounded synthetic strings with an explicit alphabet and optional affixes; use RegexStringGenerator when the entire lexical shape is best expressed as a regular expression.

Category: core.

Output: str.

1
<key name="value" generator="StringGenerator(min_len=8, max_len=12, char_set='ABC123', prefix='T-', suffix='-X')"/>

Parameters

  • min_len: int | null; Default None β€” Inclusive minimum length of the generated body.
  • max_len: int | null; Default None β€” Inclusive maximum length of the generated body.
  • char_set: str | null; Default None β€” Non-empty alphabet sampled for the generated body.
  • unique: bool; Default False β€” Whether values must be unique within the supported in-process pool.
  • prefix: str | null; Default None β€” Constant text prepended to the generated body.
  • suffix: str | null; Default None β€” Constant text appended to the generated body.

UUIDGenerator

Generate UUID version 4 identifiers from the deterministic row RNG when seeded.

Why: Use UUIDGenerator for opaque UUIDv4-shaped identifiers that remain reproducible under a seeded model; use IncrementGenerator when human-readable ordering matters.

Category: core.

Output: str.

1
<key name="value" generator="UUIDGenerator()"/>