Skip to main content

A micro test runner

Project description

microPyTest

microPyTest is a minimal, Python-based test runner that you can use directly in code.

Key Points

  • Code-first approach: Import and run tests from your own scripts.
  • Artifact tracking: Each test can record artifacts (files or data) via a built-in test context.
  • Lightweight: Just Python. No special config or advanced fixtures.
  • Optional CLI: You can also run tests via the micropytest command, but embedding in your own code is the primary focus.

Installation

pip install micropytest

Usage in Code

Suppose you have some test files under my_tests/:

# my_tests/test_example.py
def test_basic():
    assert 1 + 1 == 2

def test_with_context(ctx):
    ctx.debug("Starting test_with_context")
    assert 2 + 2 == 4
    ctx.add_artifact("numbers", {"lhs": 2, "rhs": 2})

You can run them from a Python script:

import micropytest.core

results = micropytest.core.run_tests(tests_path="my_tests")
passed = sum(r["status"] == "pass" for r in results)
total = len(results)
print("Test run complete: {}/{} passed".format(passed, total))
  • Each test that accepts a ctx parameter gets a TestContext object with .debug(), .warn(), .add_artifact(), etc.
  • Results include logs, artifacts, pass/fail status, and duration.

Differences from pyTest

If you’re coming from pytest:

  1. No fixtures or plugins

    • microPyTest is intentionally minimal. Tests can still share state by passing a custom context class if needed.
  2. No complex configuration

    • There’s no pytest.ini or conftest.py. Just put your test functions in test_*.py or *_test.py.
  3. Artifact handling is built-in

    • ctx.add_artifact("some_key", value) can store files or data for later review. No extra plugin required.
  4. Time estimates for each test

    • After each run, .micropytest.json is updated with test durations so you’ll see (est ~1.2s) next time.
  5. Code-first

    • You typically call run_tests(...) from Python scripts. The CLI is optional if you prefer it.

Quickstart

See the examples folder

Optional CLI

If you prefer a command-line flow:

micropytest [OPTIONS] [PATH]
  • -v, --verbose: Show all debug logs & artifacts.
  • -q, --quiet: Only prints a final summary.

Example:

micropytest -v my_tests

Changelog

  • v0.2 – Added support for custom context classes
  • v0.1 – Initial release

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

micropytest-0.2.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

micropytest-0.2-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file micropytest-0.2.tar.gz.

File metadata

  • Download URL: micropytest-0.2.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for micropytest-0.2.tar.gz
Algorithm Hash digest
SHA256 5e7f777e721b743f26edd023934dcd8a79e0dbc6788db589aa15258814678a9c
MD5 c1d5081fe4f91eff4b7711befd579404
BLAKE2b-256 f432f12d1513b303ed78f78e8b0c5b6d61a238214d2789209c87d3c2bee9e17e

See more details on using hashes here.

File details

Details for the file micropytest-0.2-py3-none-any.whl.

File metadata

  • Download URL: micropytest-0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for micropytest-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1bde0ac1587a17e5d0cbc6a6989a40b2430eb8056b2a875d96d35aa94f0fd3e5
MD5 b3b32d51820a17278b711783c47c416f
BLAKE2b-256 b8bc4d40b0f8be8ca690da53dd1b12f89bc3af584c6d13ea0a681a71cc675220

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