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-testing-python
    
  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-0.4.1b1.tar.gz (281.5 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file algorand_python_testing-0.4.1b1.tar.gz.

File metadata

File hashes

Hashes for algorand_python_testing-0.4.1b1.tar.gz
Algorithm Hash digest
SHA256 3ab174aab547b89a1d8418f5926d93dddd30b62f95a7811cace23ec770d34b88
MD5 a11ada13fb1524d341d0cebc3bdbb57e
BLAKE2b-256 0111df4e927a58ffed9306add0795a9e2ddb52ec0cf2aea33bbb16053871526e

See more details on using hashes here.

File details

Details for the file algorand_python_testing-0.4.1b1-py3-none-any.whl.

File metadata

File hashes

Hashes for algorand_python_testing-0.4.1b1-py3-none-any.whl
Algorithm Hash digest
SHA256 a0e8f572575d6251027010888e2100288b8d3ba3e89bc9572ba42e2a0fa920bf
MD5 1f2f35a55f249fcf14daf9a71c7513e4
BLAKE2b-256 e1b6d478831e0790d1f1e5dff366488e2316a09874ce71d38e9a8dfacde70e8d

See more details on using hashes here.

Supported by

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