Skip to main content

PocketIC Python: A Canister Testing Library

PocketIC is a local canister testing solution for the Internet Computer.
This testing library works together with the PocketIC server, allowing you to interact with your local IC instances and the canisters thereon.

With PocketIC Python, you can test your canisters with just a few lines of code, either by interacting with an IC instance:

from pocket_ic import PocketIC

pic = PocketIC()
canister_id = pic.create_canister()
pic.add_cycles(canister_id, 2_000_000_000_000)  # 2T cycles
pic.install_code(...)

# make canister calls
response = pic.update_call(canister_id, method="greet", ...)
assert(response == 'Hello, PocketIC!')

... or even directly with a canister object:

my_canister = pic.create_and_install_canister_with_candid(...)
# call your canister methods with native Python syntax
response = my_canister.greet()
assert(response == 'Hello, PocketIC!')

Getting Started

Quickstart

  • Download the latest PocketIC server from the PocketIC repo that is compatible with the library version you're using.
  • Leave the binary in your current working directory, or specify the path to the binary by setting the POCKET_IC_BIN environment variable before running your tests.
  • Run pip3 install pocket-ic in your (virtual) environment to get the Python library.
  • Use from pocket_ic import PocketIC in your Python code and start testing!

Examples

To see some working code, see the examples/ folder, or check out the how to use this library guide. To run an example, clone this repo and run python3 examples/counter_canister/counter_canister_test.py from the repository's root directory. To see a minimalistic setup of PocketIC in a Motoko project, check out the ICP Hello World Motoko repository.

Documentation

Contributing

See CONTRIBUTING.md

Metadata

Release files for pocket-ic 3.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pocket-ic 3.1.2
File Size Uploaded
pocket_ic-3.1.2.tar.gz 587.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pocket-ic 3.1.2
File Interpreter ABI Platform
pocket_ic-3.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 602.1 kB

Release files / pocket_ic-3.1.2.tar.gz

Download URL pocket_ic-3.1.2.tar.gz
Size 587.9 kB
Tags Source
SHA-256 checksum
How to use checksums
60a9f049b68005fdfb4bd7622e9528522c63faffbb5ce09f0b543f7a9ce71ef3
BLAKE2b-256 checksum
How to use checksums
0e0b922c4203e32b0fc7c98f4482e943e9d991120da7010c91f5467b078b225e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release files / pocket_ic-3.1.2-py3-none-any.whl

Download URL pocket_ic-3.1.2-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1b328fabbb257b4fa1ab9bac0d07254724d16d684ce74c8da652546fd351a658
BLAKE2b-256 checksum
How to use checksums
48aecea4dfc297c40e49820fb7ede188538cd1641e0c2913aef8bf356cfaadc4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

3.1.2 This release

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.1.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page