Skip to content

Algorand Python Testing

Offline unit testing for Algorand Python smart contracts — fast, Pythonic, network-free.

algorand-python-testing is a companion to Algorand Python and requires Python 3.12+.

Terminal window
pip install algorand-python-testing
import algopy
from algopy_testing import algopy_testing_context
class Counter(algopy.ARC4Contract):
def __init__(self) -> None:
self.count = algopy.GlobalState(algopy.UInt64(0))
@algopy.arc4.abimethod
def increment(self) -> algopy.arc4.UInt64:
self.count.value += algopy.UInt64(1)
return algopy.arc4.UInt64(self.count.value)
with algopy_testing_context() as ctx:
contract = Counter()
result = contract.increment()
assert result.as_uint64() == 1
assert contract.count.value == 1

See the Quick Start tutorial for a richer walkthrough.

Offline AVM Simulation

Emulate AVM behaviour in pure Python — no sandbox, no network, no waiting.

ARC4 Support

First-class testing for ARC4Contract classes, ABI methods, and ARC4 types.

Transaction & State Helpers

Build transaction groups, manage global/local/box state, and inspect inner txns.

pytest-native

Plain Python tests — works with pytest, unittest, and hypothesis out of the box.