Skip to main content

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:

  1. Ensure you have Python 3.12+

  2. Install AlgoKit CLI

  3. Install Algorand Python Testing into your project:

    pip install algorand-python-testing
    
  4. 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():
        with algopy_testing_context() as context:
            # Arrange
            contract = YourContract()
            expected_result = ... # Your expected result here
    
            # Act
            result = contract.your_method(context.any.uint64())  # Your test code here
    
            # Assert
            assert result == expected_result
    
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

algorand_python_testing-1.1.0.tar.gz (474.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

algorand_python_testing-1.1.0-py3-none-any.whl (96.1 kB view details)

Uploaded Python 3

File details

Details for the file algorand_python_testing-1.1.0.tar.gz.

File metadata

  • Download URL: algorand_python_testing-1.1.0.tar.gz
  • Upload date:
  • Size: 474.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for algorand_python_testing-1.1.0.tar.gz
Algorithm Hash digest
SHA256 7b2e0129bf3157db430ff1e1dabb052e9905039a89c769715bdc338071589cf2
MD5 49ab01e8ab00460f7dbcfb1a45b12f6f
BLAKE2b-256 e68aa891432b3538dda610e8482893efb8a982508d1bac2adb33dd11c5351c68

See more details on using hashes here.

Provenance

The following attestation bundles were made for algorand_python_testing-1.1.0.tar.gz:

Publisher: cd.yaml on algorandfoundation/algorand-python-testing

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file algorand_python_testing-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for algorand_python_testing-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ff753c5e4e0e5a65664e0b8b974d4206c91768fc19b3b24184fd3d00f66ada9
MD5 1e9498ac14fbcc7f9034b0a828cf647d
BLAKE2b-256 7676299a87ed691036971d723e21078802ebc78a325da5b3540fd07b10a75c13

See more details on using hashes here.

Provenance

The following attestation bundles were made for algorand_python_testing-1.1.0-py3-none-any.whl:

Publisher: cd.yaml on algorandfoundation/algorand-python-testing

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page