Value Generators
The AlgopyTestContext exposes value generators via its any property. They produce randomized but constrained values for AVM entities (accounts, assets, applications, transactions, ARC4 types) so tests can focus on behaviour rather than fixture plumbing.
import algopyfrom algopy_testing import algopy_testing_context
with algopy_testing_context() as ctx: sender = ctx.any.account() payment = ctx.any.txn.payment(sender=sender, amount=algopy.UInt64(10_000)) arc4_string = ctx.any.arc4.string(n=10)Generator namespaces
Section titled “Generator namespaces”The any property exposes three generator surfaces:
AVMValueGenerator: Base abstractions for AVM types. All methods are available directly on the instance returned fromany(e.g.any.account(),any.asset(),any.uint64()).TxnValueGenerator: Accessible viaany.txn, for transaction-related data (e.g.any.txn.payment(...),any.txn.application_call(...)).ARC4ValueGenerator: Accessible viaany.arc4, for ARC4 type data (e.g.any.arc4.string(...),any.arc4.uint64(...)).
For full method signatures, see the API reference:
Tip
Value generators are powerful tools for generating test data for specified AVM types. They allow further constraints on random value generation via arguments, making it easier to generate test data when exact values are not necessary.
When used with the ‘Arrange, Act, Assert’ pattern, value generators can be especially useful in setting up clear and concise test data in arrange steps.
They can also serve as a base building block that can be integrated/reused with popular Python property-based testing frameworks like hypothesis.