|
| 1 | +# Algorand Python Testing |
| 2 | + |
| 3 | +Algorand Python Testing is a companion package to [Algorand Python](https://github.com/algorandfoundation/puya) 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. |
| 4 | + |
| 5 | +[Documentation](https://algorandfoundation.github.io/algopy_testing/index.html) | [Algorand Python Documentation](https://algorandfoundation.github.io/puya/) |
| 6 | + |
| 7 | +## Quick start |
| 8 | + |
| 9 | +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. |
| 10 | + |
| 11 | +Alternatively, if you want to start from scratch: |
| 12 | + |
| 13 | +1. Ensure you have Python 3.12+ |
| 14 | +2. Install [AlgoKit CLI](https://github.com/algorandfoundation/algokit-cli?tab=readme-ov-file#install) |
| 15 | +3. Install Algorand Python Testing into your project: |
| 16 | + ```bash |
| 17 | + pip install algopy-testing-python |
| 18 | + ``` |
| 19 | +4. Create a test file (e.g., `test_contract.py`): |
| 20 | + |
| 21 | + ```python |
| 22 | + from algopy_testing import algopy_testing_context |
| 23 | + from your_contract import YourContract |
| 24 | +
|
| 25 | + def test_your_contract(): |
| 26 | + with algopy_testing_context() as ctx: |
| 27 | + contract = YourContract() # Your test code here |
| 28 | + ``` |
| 29 | + |
| 30 | +5. Run your tests using your preferred Python testing framework (e.g., pytest, unittest) |
| 31 | + |
| 32 | +For more detailed information, check out the [full documentation](https://algorandfoundation.github.io/algopy_testing). |
| 33 | + |
| 34 | +## Features |
| 35 | + |
| 36 | +- Offline testing environment simulating core AVM functionality |
| 37 | +- Compatible with popular Python testing frameworks |
| 38 | +- Supports testing of ARC4 contracts, smart signatures, and more |
| 39 | +- Provides tools for mocking blockchain state and transactions |
| 40 | + |
| 41 | +## Examples |
| 42 | + |
| 43 | +For detailed examples showcasing various testing scenarios, refer to the [examples section](https://algorandfoundation.github.io/algopy_testing/examples.html) in the documentation. |
| 44 | + |
| 45 | +## Contributing |
| 46 | + |
| 47 | +We welcome contributions to this project! Please read our [contributing guide](CONTRIBUTING.md) to get started. |
0 commit comments