pytest_kustomize
Parse and validate kustomize output
Example
from pytest_kustomize import resolve_configmaps, extract_externalsecret_data
import pytest
@pytest.mark.parametrize("environment, value", [
("staging", "shared-db.staging.example.com"),
("production", "myservice-db.production.example.com"),
])
def test_database_matches_environment(kustomize_resources, environment, value):
config = resolve_configmaps(kustomize_resources[environment])
for deployment in ["webui", "api"]:
assert config[deployment]["db_host"] == value
def test_production_has_no_staging_vault_paths(kustomize_resources):
for secret in extract_externalsecret_data(kustomize_resources["production"]).values():
assert "staging" not in secret["key"]
@pytest.mark.parametrize("environment", ["staging", "production"])
def test_jq(kustomize_jq, environment):
for apiVersion in kustomize_jq(
""".[] | select(."kind"=="ConfigMap").apiVersion""", environment
):
assert apiVersion == "v1"
Usage
You can access the kustomize output as follows:
- The
kustomize_manifestsfixture returns adict[str, str], environment name:kustomize buildoutput - The
kustomize_resourcesfixture returns adict[str, List[dict]], environment name: yaml-parsed output - The
kustomize_jqfixture returns a query helper which applies ato the given environment and returns an instance of
. Only available by explicitly installing
jq(orpytest_kustomize[jq])
Optionally, define the directory where kustomize manifests are looked up by providing this fixture
@pytest.fixture(scope="session")
def kustomize_root_directory():
return "/path/to/kustomizations"
Default: ./k8s
Optionally, define for which subdirectories manifests should be generated by providing this fixture
@pytest.fixture(scope="session")
def kustomize_environment_names():
return ["overlays/staging", "overlays/production"]
Default: All direct subdirectories that contain a kustomization.yaml
API
The package provides these helper functions:
resolve_configmaps()resolvesenvFromreferences toConfigMaps inDeployments. It takes a list of yaml dicts (usuallykustomize_resources[environment]) and returns adict[str, dict[str, str]], deployment+container name: {key: value}. The dict keys work as follows:- Containers are named
{deployment}-{container} - Init Containers are named
{deployment}-init-{container} - For convenience, the first container is also available just under the name
{deployment}, and the first init container as{deployment}-init
- Containers are named
extract_externalsecret_data()extracts thedatasections of allExternalSecretresources. It takes a list of yaml dicts and returns{"key_in_secret": {"key": "example/vault/path", "property": "token"}}
These take an optional name_transform callable which defaults to lambda x: x.rsplit('-', 1)[0], to normalize e.g. kustomize-generated ConfigMap names like project-44fb7dkk64.
pytest_kustomize Changes
1.3.1 (2025-12-08)
- Make jq an optional dependency (jq)
1.3.0 (2025-12-08)
- Make jq an optional dependency (jq)
1.2.0 (2025-10-02)
- Allow querying manifests via jq
1.1.0 (2025-07-09)
- Parse all containers and initContainers in
resolve_configmaps(initcontainer) - Normalize names by splitting on the last dash, not the first (nametrans)
1.0.0 (2025-07-03)
- Initial release (initial)
Metadata
Release files for pytest_kustomize 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytest_kustomize-1.3.1.tar.gz | 57.0 kB | Without provenance | Details for pytest_kustomize-1.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_kustomize-1.3.1-py3-none-any.whl | Python 3 | none | any | Details for pytest_kustomize-1.3.1-py3-none-any.whl |
Total release size: 61.6 kB
Release files / pytest_kustomize-1.3.1.tar.gz
| Download URL | pytest_kustomize-1.3.1.tar.gz |
|---|---|
| Size | 57.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c729395a27ffbd803a60c251444db1856745ebaec4ac23fe6a02f80dcd45fabc
|
|
BLAKE2b-256 checksum How to use checksums |
2319263171626fa4dc46b1311e07633a96cde2e41dea0103f5183d65189987b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / pytest_kustomize-1.3.1-py3-none-any.whl
| Download URL | pytest_kustomize-1.3.1-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0dc01ffcbd72f4b0a5d696d4610db8f796b4765783cf21f93aa1e2b44c4bcae6
|
|
BLAKE2b-256 checksum How to use checksums |
6958712d998effa32057418f5bddecde2b83b11e51e68941bb4049a936120d6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for pytest_kustomize 1.3.1
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.