Skip to main content

A micro test runner

Project description

microPyTest

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

screenshot.png

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/skip 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

  5. Code-first

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

Quickstart

See the examples subfolder

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.3.1 – Fixed screenshot in pypi
  • v0.3 – Added ability to skip tests
  • v0.2 – Added support for custom context classes
  • v0.1 – Initial release

Enjoy your micro yet mighty test runner!

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.3.1.tar.gz (10.3 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.3.1-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for micropytest-0.3.1.tar.gz
Algorithm Hash digest
SHA256 eaaf6729560fa43bc35cd9b3e5dc46c51756d0fe39b090697b3065465883698d
MD5 a01d5300e2c71c610ca8bbb702f2b7e1
BLAKE2b-256 9ba94e4bae6ed0cbc6a8949c0840fcc068ae62a6ebc834552c454d6f7eb99c9d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: micropytest-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 9.9 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.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ead074288ea5e5d0530baf5584724da935aa96d841bfd117677e33edbeaa6748
MD5 bd66d9e1c4715c05998027de5d93b0a5
BLAKE2b-256 c9c782363663eeeca2a6eac532da8be9d97d2e57a4c80407e33994708891c0ff

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