Algorand Python testing library
Project description
Algorand Python Testing is a companion package to Algorand Python that enables efficient unit testing of Algorand Python smart contracts in an offline environment. It emulates key AVM behaviors without requiring a network connection, offering fast and reliable testing capabilities with a familiar Pythonic interface.
Documentation | Algorand Python Documentation
Quick start
The easiest way to use Algorand Python Testing is to instantiate a template with AlgoKit via algokit init -t python
. This will give you a full development environment with testing capabilities built-in.
Alternatively, if you want to start from scratch:
-
Ensure you have Python 3.12+
-
Install AlgoKit CLI
-
Install Algorand Python Testing into your project:
pip install algorand-testing-python
-
Create a test file (e.g.,
test_contract.py
):from algopy_testing import algopy_testing_context from your_contract import YourContract def test_your_contract(): # Arrange contract = YourContract() expected_result = ... # Your expected result here # Act result = contract.your_method() # Your test code here # Assert assert result == expected_result
-
Run your tests using your preferred Python testing framework (e.g., pytest, unittest)
For more detailed information, check out the full documentation.
Features
- Offline testing environment simulating core AVM functionality
- Compatible with popular Python testing frameworks
- Supports testing of ARC4 contracts, smart signatures, and more
- Provides tools for mocking blockchain state and transactions
Examples
For detailed examples showcasing various testing scenarios, refer to the examples section in the documentation.
Contributing
We welcome contributions to this project! Please read our contributing guide to get started.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file algorand_python_testing-0.3.0b10.tar.gz
.
File metadata
- Download URL: algorand_python_testing-0.3.0b10.tar.gz
- Upload date:
- Size: 270.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4a75c95ab055c8e2744fd91ac506d1889dce3df5297138a1d194bc9a734b0be |
|
MD5 | 85082c2074777d18847bdc92e173e09b |
|
BLAKE2b-256 | 1fa2714a55a59b97021c364b21513ca85909bd1fefe326496bb0e571db196fde |
File details
Details for the file algorand_python_testing-0.3.0b10-py3-none-any.whl
.
File metadata
- Download URL: algorand_python_testing-0.3.0b10-py3-none-any.whl
- Upload date:
- Size: 84.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2d3cb727f223b8344c8f4c2ea6d368555a7aa411038564c23e630c39d5e1076 |
|
MD5 | 8c3771c9f9d2250de991cbea4ae21522 |
|
BLAKE2b-256 | f489ef451d6d5aed01c6e159066b29e6b3d48914166fd128b040c512281ea7ef |