# 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`:
```python
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](docs/reference.md).
Raw data
{
"_id": null,
"home_page": "https://github.com/juju-solutions/charms.unit_test",
"name": "charms.unit-test",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Cory Johns",
"author_email": "johnsca@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/e8/e5/7bf6843dee5e645f754e59618f593dcd0fd6fa9123ee756ad51299cc5f20/charms.unit_test-1.1.2.tar.gz",
"platform": null,
"description": "# charms.unit\\_test\n\nThis library provides helpers for unit testing reactive style charms,\nlayers, and interfaces.\n\n\n## Usage\n\nThis library is intended to be used with pytest and `conftest.py`, which\nallows for mocking out imports prior to the test code being loaded.\n\nExample `conftest.py`:\n\n```python\nfrom charms.unit_test import patch_reactive, patch_module\n\n# patch common things needed by any reactive charm\npatch_reactive()\n\n# patch some other module that the charm expects to be there\npatch_module('charms.leadership')\n```\n\nWith this, your test code can import the charm's reactive code which\ndepends on charms.reactive and charmhelpers without error, and the\nlibraries will be mocked out so that you can call your handlers\ndirectly to test them.\n\n\n## Reference\n\nMore details on what is patched, as well as what other helpers are available,\ncan be found in [the reference docs](docs/reference.md).\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "Helpers for unit-testing reactive-style Juju Charms",
"version": "1.1.2",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "b24a622336a9f50046b03b8dc4856b80",
"sha256": "34975206e2716d7cb96e0f58c943a0071be8e100d4de424ed71f3a2a1a43c7bf"
},
"downloads": -1,
"filename": "charms.unit_test-1.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b24a622336a9f50046b03b8dc4856b80",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5628,
"upload_time": "2022-12-07T17:02:35",
"upload_time_iso_8601": "2022-12-07T17:02:35.048569Z",
"url": "https://files.pythonhosted.org/packages/16/6d/421dd9d4b9970660179c2c8dc369dae7a6fd2b3646566b2f7bec55ee2e84/charms.unit_test-1.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "55ae164faba1f7dfd58bdf6bb39bf325",
"sha256": "5311d7bc9ded480650b089d1ff619d8420ac6188cb1ff2bb918f4885be200f27"
},
"downloads": -1,
"filename": "charms.unit_test-1.1.2.tar.gz",
"has_sig": false,
"md5_digest": "55ae164faba1f7dfd58bdf6bb39bf325",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5503,
"upload_time": "2022-12-07T17:02:37",
"upload_time_iso_8601": "2022-12-07T17:02:37.221743Z",
"url": "https://files.pythonhosted.org/packages/e8/e5/7bf6843dee5e645f754e59618f593dcd0fd6fa9123ee756ad51299cc5f20/charms.unit_test-1.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-07 17:02:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "juju-solutions",
"github_project": "charms.unit_test",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "charms.unit-test"
}