A micro test runner
Project description
microPyTest
microPyTest is a minimal, pure 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
micropytestcommand, 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
ctxparameter 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:
-
No fixtures or plugins
microPyTest is intentionally minimal. Tests can still share state by passing a custom context class if needed.
-
No complex configuration
There’s no
pytest.iniorconftest.py. Just put your test functions intest_*.pyor*_test.py. -
Artifact handling is built-in
ctx.add_artifact("some_key", value)can store files or data for later review. No extra plugin required. -
Time estimates for each test
-
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 – 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file micropytest-0.3.tar.gz.
File metadata
- Download URL: micropytest-0.3.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82ec47d01cdcabaa06991e43a7063e785bf42716438e0f66ae7f2871fc10295f
|
|
| MD5 |
c246f20e95f33591b056a982a6a9aa59
|
|
| BLAKE2b-256 |
394d2a29c4f1d0524b6086a9d106df1aebbfce532c1f293f4a9e251eb7404650
|
File details
Details for the file micropytest-0.3-py3-none-any.whl.
File metadata
- Download URL: micropytest-0.3-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
968c3bbdabb20aeafc26add75ccf96b62043e71c391334ee0abce3bf8cd73712
|
|
| MD5 |
c0ea1ccd95a7405c6176bec864b215b7
|
|
| BLAKE2b-256 |
5d42ca39929370e7d5aaa03fe4272735ffc8deb53be57022ea64a1aae7b03a29
|