Skip to main content
# pytest-inmanta

A pytest plugin to test inmanta modules

## Installation

```bash
pip install pytest-inmanta
```

## Usage

This plugin provides a test fixture that can compile, export and deploy code without running an actual inmanta server.

```python
def test_compile(project):
"""
Test compiling a simple model that uses std
"""
project.compile("""
host = std::Host(name="server", os=std::linux)
file = std::ConfigFile(host=host, path="/tmp/test", content="1234")
""")
```

The fixture also provides access to the model internals

```python
assert len(project.types["std::Host"].get_all_instances()) == 1
```

To the exported resources

```python
f = project.get_resource("std::ConfigFile")
assert f.permissions == 644
```

To compiler output and mock filesystem

```python
def test_template(project):
"""
Test the evaluation of a template
"""
project.add_mock_file("templates", "test.tmpl", "{{ value }}")
project.compile("""import unittest
value = "1234"
std::print(std::template("unittest/test.tmpl"))
""")

assert project.get_stdout() == "1234\n"
```

And allows deploy

```python
project.deploy_resource("std::ConfigFile")
```

## Options

The following options are available.

* --venv: folder in which to place the virtual env for tests (will be shared by all tests), overrides INMANTA_TEST_ENV.
This options depends on symlink support. This does not work on all windows versions. On windows 10 you need to run pytest in an
admin shell.
* --module_repo: location to download modules from, overrides INMANTA_MODULE_REPO. The default value is the inmanta github organisation.

Use the generic pytest options `--log-cli-level` to show Inmanta logger to see any setup or cleanup warnings. For example,
`--log-cli-level=INFO`

Metadata

Release files for pytest-inmanta 0.5.0

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

Source distribution (sdist)

Source distribution for pytest-inmanta 0.5.0
File Size Uploaded Provenance Actions
pytest-inmanta-0.5.0.tar.gz 5.9 kB Without provenance Details for pytest-inmanta-0.5.0.tar.gz

Release files / pytest-inmanta-0.5.0.tar.gz

Download URL pytest-inmanta-0.5.0.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b8eaebce9c3dd8fb44776fb7f9c4869c08c85675c34245fa78c64c3b6e008727
BLAKE2b-256 checksum
How to use checksums
1259759ec84bba72e203a8010ebc818db8d55801dcc8b10a16af0e4ff1daa956
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.4.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Security for pytest-inmanta 0.5.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.0 This release

1 release file No provenance

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