Skip to main content

Helpers for unit-testing reactive-style Juju Charms

Project description

charms.unit_test

This library provides helpers for unit testing reactive style charms.

Usage

This library is intended to be used with pytest and conftest.py, which allows for mocking out imports prior to the test code being loaded.

Example conftest.py:

from charms.unit_test import patch_reactive, patch_module

# patch common things needed by any reactive charm
patch_reactive()

# patch some other module that the charm expects to be there
patch_module('charms.leadership')

With this, your test code can import the charm's reactive code which depends on charms.reactive and charmhelpers without error, and the libraries will be mocked out so that you can call your handlers directly to test them.

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

charms.unit_test-1.0.2.tar.gz (4.9 kB view details)

Uploaded Source

File details

Details for the file charms.unit_test-1.0.2.tar.gz.

File metadata

  • Download URL: charms.unit_test-1.0.2.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for charms.unit_test-1.0.2.tar.gz
Algorithm Hash digest
SHA256 ed5934eaf66f1d6b549605be0257c2a691f0efc1f6c8d55ce72d9361e6f7cb22
MD5 05f767af10e1b526f284f1163fd9cb9f
BLAKE2b-256 d9f51c7171d84900abd3db3c0f8b5365559f0c5642d946eb2e817c757f94d8b7

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