Skip to main content

Python automated test framework

Project description

vault88

vault88 is a Python automated test framework designed for structured hardware and software validation in CI/CD pipelines. Tests are written as Python classes, organised into stages, and results can be published through configurable reporters.

Architecture

Component Role
Loader Discovers test classes from files or directories; supports tag-based include/exclude filtering
Logger Centralised logging with rotating file handler and optional verbose (debug) output
Runner Instantiates and executes a test class through its full lifecycle: selfChecksetuprunteardown
Reporter Pluggable reporters loaded from the config file; built-in reporters include HTML, JUnit XML, PDF, and log archive

Test results are grouped into named stages within each test, and each result records an action, expected value, actual value, outcome, timestamp, and optional requirement references.

Installation

pip install vault88

Or with uv:

uv add vault88

Writing a test

Subclass Test and implement the four lifecycle methods:

from vault88 import Test

class MyTest(Test):
    name = "My Test"
    tags = ["smoke"]

    def selfCheck(self) -> bool:
        # Return False to skip the test entirely
        return True

    def setup(self) -> bool:
        # Prepare resources; return False to abort
        return True

    def run(self) -> None:
        self.newStage("Basic checks")
        self.assertEqual("Verify result", expected=42, actual=compute())

    def teardown(self) -> None:
        pass

Available assertion helpers: assertEqual, assertNotEqual, assertTrue, assertFalse, assertGreaterThan, assertLessThan, assertGreaterThanOrEqual, assertLessThanOrEqual, assertIn, assertNotIn, assertIsNone, assertIsNotNone.

Running tests

vault88 <testpath> [options]
Option Description
testpath Path to a test file or directory
-t TAG [TAG ...] Only run tests that have at least one of these tags
-nt TAG [TAG ...] Exclude tests that have any of these tags
-r Recursively search directories for tests
-l FILE Log file path (default: ./test_execution.log)
-v Verbose / debug logging
--env PATH_OR_URL Load an environment from a JSON file or HTTP(S) URL
--junit Generate a testresults.xml JUnit report in the current directory
--dry-run Discover and list matching tests without running them, then exit
--workers N Run up to N tests concurrently (default: 1, sequential)
--output-dir PATH Write all reporter output to this directory
--config PATH Config file path (overrides ~/.vault88.conf and /etc/vault88.conf)

Environments

An environment passes host addresses, service details, and credentials into tests at runtime so the same test class can run against different targets without code changes.

Environment file format

Environments are defined as JSON. Credentials are declared in a top-level credentials dict and referenced by name from services. Hosts use the "host" key for their address:

{
  "name": "staging",
  "credentials": {
    "deploy-key": {
      "type": "username-password",
      "username": "deploy",
      "key_path": "/home/ci/.ssh/id_rsa"
    }
  },
  "hosts": [
    {
      "host": "10.0.1.10",
      "name": "app-server",
      "services": [
        { "name": "ssh", "port": 22, "creds": "deploy-key" },
        { "name": "api", "port": 8080, "url": "http://10.0.1.10:8080" }
      ]
    }
  ]
}

String values in the JSON can reference shell environment variables using ${VAR_NAME} — useful for keeping credentials out of files checked into version control. Unset variables are left as-is.

Loading an environment

Pass the file path or an HTTP(S) URL to --env:

# from a local file
vault88 tests/ --env ./staging.json

# from an API endpoint
vault88 tests/ --env https://inventory.example.com/envs/staging

The API loader expects the endpoint to return the same JSON structure.

Using the environment in a test

The loaded Environment object is available as self.environment. Walk the hosts list or look up a host by name:

from vault88 import Test

class DeploymentTest(Test):
    name = "Deployment smoke test"
    tags = ["smoke"]

    def selfCheck(self) -> bool:
        return self.environment is not None

    def setup(self) -> bool:
        return True

    def run(self) -> None:
        self.newStage("Connectivity")

        host = next(h for h in self.environment.hosts if h.name == "app-server")
        api = next(s for s in host.services if s.name == "api")

        response = requests.get(f"{api.url}/health")
        self.assertEqual("Health endpoint returns 200", expected=200, actual=response.status_code)

    def teardown(self) -> None:
        pass
Attribute Type Description
environment.name str Environment name from the JSON
environment.hosts List[Host] All hosts in the environment
host.address str IP address or hostname (from the "host" JSON key)
host.name str | None Optional friendly label
host.services List[Service] Services running on the host
service.name str Service label
service.port int | None Port number
service.url str | None Full URL
service.credential Credential | None Resolved credential (from the "creds" reference)
credential.type str "username-password" or "token"
credential.username str | None Username
credential.password str | None Password
credential.key_path str | None Path to a private key file
credential.token str | None Token string

Configuration

The config file is read from the first location found: --config PATH (CLI flag) → ~/.vault88.conf/etc/vault88.conf. It uses INI format.

To generate a starter config file in the current directory, run:

vault88 --init-config

This writes vault88.conf with width = 100, template = blueprint, and a disabled entry for every built-in reporter. Move the file to ~/.vault88.conf or pass it via --config vault88.conf to activate it.

Console output

All terminal output is rendered through a console template. Configure it in the [CONSOLE] section of the config file.

Selecting a template

[CONSOLE]
template = default
Value Effect
default (or omitted) Use the built-in DefaultTemplate
blueprint Use the built-in BlueprintTemplate (box-framed stage headers, symbol-prefixed steps)
diagnostic Use the built-in DiagnosticTemplate (compiler/linter-style output with outcome-coloured bullets)
token Use the built-in TokenTemplate (keyword-coloured stage headers, right-aligned timestamps)
mypackage.console.MyTemplate Load a custom template class by its full dotted Python path

If the custom class cannot be imported, vault88 logs a warning and falls back to DefaultTemplate.

DefaultTemplate options

Key Default Description
width auto-detected Output width in characters (falls back to 80 if terminal detection fails)
stage_color (none) ANSI color applied to stage header lines
step_color (none) ANSI color applied to the Step N-N: prefix
timestamp_format %H:%M:%S strftime format string for step timestamps
timestamp_position field Where timestamps appear: field (own line) or inline (after step number)

Available color names: black, red, green, yellow, blue, magenta, cyan, white, bright_black, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white.

[CONSOLE]
width = 120
stage_color = cyan
step_color = bright_blue
timestamp_format = %Y-%m-%d %H:%M:%S
timestamp_position = inline

See docs/console-templates.md for the full template API and a custom template example.

Reporters

Each [REPORTER<n>] section loads one reporter:

[REPORTER1]
module = vault88.core.reporters.html_reporter
class = HtmlReporter
enabled = true
output_dir = ./reports

[REPORTER2]
module = vault88.core.reporters.junit_reporter
class = JUnitReporter
enabled = true
suite_name = My Project Tests

[REPORTER3]
module = vault88.core.reporters.pdf_reporter
class = PdfReporter
enabled = true
output_dir = ./reports

[REPORTER4]
module = vault88.core.reporters.log_archive_reporter
class = LogArchiveReporter
enabled = true
output_dir = ./logs

Use --output-dir PATH on the CLI to redirect all reporter output to a single directory, overriding each reporter's output_dir config value.

License

MIT License

Copyright (c) 2025 Brad Murdoch

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

vault88-0.3.9.tar.gz (56.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vault88-0.3.9-py3-none-any.whl (43.1 kB view details)

Uploaded Python 3

File details

Details for the file vault88-0.3.9.tar.gz.

File metadata

  • Download URL: vault88-0.3.9.tar.gz
  • Upload date:
  • Size: 56.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for vault88-0.3.9.tar.gz
Algorithm Hash digest
SHA256 3d332d49b6b194ecca07c3bc6aae79552c3d2f33ecaceafe1fe44dcdd7eae379
MD5 3e8146371d59028ffcf905fcc0fd61c0
BLAKE2b-256 79e13c6d8bc880594ebbe7534005b127ae4d7d8d429e95cee2f871bb530d5bc5

See more details on using hashes here.

File details

Details for the file vault88-0.3.9-py3-none-any.whl.

File metadata

  • Download URL: vault88-0.3.9-py3-none-any.whl
  • Upload date:
  • Size: 43.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for vault88-0.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 6b94fc33ae8c89a9fee64cc0322c4998d22b254c11334c1e5fe913bf117a160f
MD5 39a93173fce2bde869fb7a85a27b0aae
BLAKE2b-256 cd0637f5e2c1b6026349e28fa46a31eb9b7cbcec969ac1150edd5fbe86e41066

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page