_algopy_testing.context

Module Contents

Classes

AlgopyTestContext

Manages the testing context for Algorand Python SDK (algopy) applications.

API

class AlgopyTestContext(
*,
default_sender: str | None = None,
template_vars: dict[str, Any] | None = None,
)

Manages the testing context for Algorand Python SDK (algopy) applications.

This class provides methods and properties to simulate various aspects of the Algorand blockchain environment, including accounts, assets, applications, transactions, and global state. It allows for easy setup and manipulation of test scenarios for algopy-based smart contracts and applications.

Parameters:
  • default_sender – The default sender account address, defaults to None

  • template_vars – Dictionary of template variables, defaults to None

Initialization

property default_sender: algopy.Account

Get the default sender account.

Returns:

The default sender account

Return type:

algopy.Account

property any: _algopy_testing.value_generators.AlgopyValueGenerator

Access the value generators.

Returns:

The value generator

Return type:

AlgopyValueGenerator

property ledger: _algopy_testing.context_helpers.LedgerContext

Access the ledger context.

Returns:

The ledger context

Return type:

LedgerContext

property txn: _algopy_testing.context_helpers.TransactionContext

Access the transaction context.

Returns:

The transaction context

Return type:

TransactionContext

set_template_var(name: str, value: Any) None

Set a template variable for the current context.

Parameters:
  • name – The name of the template variable

  • value – The value to assign to the template variable

execute_logicsig(
lsig: algopy.LogicSig,
*args: algopy.Bytes,
) bool | algopy.UInt64

Execute a logic signature using provided args.

clear_transaction_context() None

Clear the transaction context.

reset() None

Reset the test context to its initial state, clearing all data and resetting ID counters.