Skip to main content

Pytest plugin for the Pico ecosystem: isolated containers by default and a make_container fixture.

Project description

pico-testing

PyPI version License: MIT CI codecov Docs

Pytest plugin for the pico ecosystem: isolated containers by default and a make_container fixture with automatic shutdown.

Why

Any pico_boot.init() in a test auto-discovers every pico plugin installed in the venv — so a test suite passes or fails depending on what else happens to be installed. Every pico project ends up copying the same two conftest fixtures. This plugin ships them once:

  • Isolation by default: PICO_BOOT_AUTO_PLUGINS=false is set for every test. Opt back in per-test with @pytest.mark.pico_auto_plugins.
  • make_container: builds containers from explicit modules and config, and shuts them all down on teardown.

Installation

pip install pico-testing

No conftest wiring — installing it activates the plugin.

Quick start

import sys

def test_my_service(make_container):
    container = make_container(
        "my_package",
        config={"my_prefix": {"key": "value"}},
    )
    service = container.get(MyService)
    assert service.do_something() == "expected"

make_container(*modules, config=None, boot=False):

  • modules: module objects or import strings, passed to init(modules=[...]).
  • config: a plain dict (wrapped in configuration(DictSource(...))) or a ready configuration(...) object.
  • boot=True: use pico_boot.init instead of pico_ioc.init (plugin auto-discovery still off unless the test is marked).

Re-enable plugin auto-discovery for a single test:

import pytest

@pytest.mark.pico_auto_plugins
def test_full_boot(make_container):
    container = make_container(boot=True)

Documentation

Full documentation: https://dperezcabrera.github.io/pico-testing/

License

MIT

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

pico_testing-0.1.0.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

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

pico_testing-0.1.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file pico_testing-0.1.0.tar.gz.

File metadata

  • Download URL: pico_testing-0.1.0.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pico_testing-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0b87410da32ea7fdfe2a5df2131cf2e3ffc411b263373689307db9777c5150ac
MD5 7829d59bcdbb0036cd2099c403883653
BLAKE2b-256 01b391df831bd475798fdb5bd20efaf736f4c3fbca8e0a2fb609612c25d6c83e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pico_testing-0.1.0.tar.gz:

Publisher: publish-to-pypi.yml on dperezcabrera/pico-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 pico_testing-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pico_testing-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pico_testing-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6ac8720e31020d6087afeb13302df24186fc15fba94a68d510f4cd41a9c7fc40
MD5 44439883128be1e3590a44217f650c23
BLAKE2b-256 4685ea6f070a00cc6281c6b8e93577bc627b5cdd2953bb4e46d5cabb4cb00ee1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pico_testing-0.1.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on dperezcabrera/pico-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