Helpers for unit-testing reactive-style Juju Charms
Project description
charms.unit_test
This library provides helpers for unit testing reactive style charms, layers, and interfaces.
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.
Reference
More details on what is patched, as well as what other helpers are available, can be found in the reference docs.
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
Built Distribution
File details
Details for the file charms.unit_test-1.1.2.tar.gz
.
File metadata
- Download URL: charms.unit_test-1.1.2.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5311d7bc9ded480650b089d1ff619d8420ac6188cb1ff2bb918f4885be200f27 |
|
MD5 | 55ae164faba1f7dfd58bdf6bb39bf325 |
|
BLAKE2b-256 | e8e57bf6843dee5e645f754e59618f593dcd0fd6fa9123ee756ad51299cc5f20 |
File details
Details for the file charms.unit_test-1.1.2-py3-none-any.whl
.
File metadata
- Download URL: charms.unit_test-1.1.2-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34975206e2716d7cb96e0f58c943a0071be8e100d4de424ed71f3a2a1a43c7bf |
|
MD5 | b24a622336a9f50046b03b8dc4856b80 |
|
BLAKE2b-256 | 166d421dd9d4b9970660179c2c8dc369dae7a6fd2b3646566b2f7bec55ee2e84 |