Skip to main content

Ongtrum

Ongtrum is a Python test runner designed for speed

Installation: pip install python-ongtrum

Why Ongtrum is Fast ?

Scan

Recursively scans for test files in the project directory with a Cython-optimized filesystem scanner

Parse

Each file is parsed with a Cython-optimized AST parser

Execute

For each file, all its test classes and methods are executed in one go using Python’s exec
To reduce overhead, files are processed in batches, keeping worker processes alive throughout the run

Optional Parallelism

Tests can be run across multiple processes with --workers

Benchmark

Execution Commands:

  • Unittests: python -m unittest discover <Project Dir>
  • PyTest: python -m pytest <Project Dir> -s -q
  • Ongtrum: python -m ongtrum.py' -q -p <Project Dir>

Test Files: 5440
Test Class: 10880

  • Unittests: 12.462s
  • PyTest: 27.217s
  • Ongtrum: 5.950s (vs Unittests 2 × Faster, vs PyTest 4.5 × Faster)

Features

Test Suites

Organize tests into named suites using the @suites decorator

from ongtrum.annotation import suites


class TestSuite:
    @suites(['suite_one', 'suite_two'])
    def test_dummy_1(self):
        assert 1 == 1

Test Parameters

Ongtrum allows you to define multiple sets of input values for a test method using the @parameters decorator
Each dictionary represents a different test case

from ongtrum.annotation import parameters


class TestParameter:
    @parameters([{'a': 1, 'b': 2}, {'a': 10, 'b': 20}])
    def test_add(self, a, b):
        assert a in [1, 10]
        assert b in [2, 20]

Test Preps

Ongtrum allows you to define reusable preparation functions (“preps”) in dedicated prep files,
which are automatically loaded for your tests <>

Scopes:

  • Session - Run once per test session - Useful for expensive setup shared by all tests - Cached for the session
  • class - Run once per test class - Shared among all methods in that class - Cached for the class
  • method - Run for each test method individually - Re-run for every method call

Configuration File

By default, Ongtrum looks for an ongtrum.yaml file:

  • At the project root when running a directory
  • In the parent directory when running a single test file

Alternatively, you can specify a config file explicitly using ongtrum -c path/to/ongtrum.yaml

Configuration Example

prep_files:
  - preps/session_preps.py
  - preps/class_preps.py
  - preps/method_preps.py

Declaring a Prep

from ongtrum.annotation import prep


@prep(scope='session')
def session_prep():
    return 'Session Prep'


@prep(scope='class')
def class_prep():
    return 'Class Prep'


@prep(scope='method')
def method_prep():
    return 'Method Prep'

Applying a Prep

from ongtrum.annotation import preps


@preps('class_prep')
class TestExample:

    @preps('method_prep')
    def test_something(self, method_prep):
        assert self.class_prep == 'Class Prep'
        assert method_prep == 'Method Prep'

Test Filter

You can run a subset of tests using the -f / --filter option
Filter format: <File>.<Class>.<Method>
You can also use wildcards (*) for flexible matching

Examples:

ongtrum -p tests/test_example.py -f test_example
ongtrum -p tests/test_example.py -f test_example.TestClass
ongtrum -p tests/test_example.py -f test_example.TestClass.test_method

ongtrum -p tests/test_example.py -f *.TestClass
ongtrum -p tests/test_example.py -f *.*.test_method

Metadata

Release files for python-ongtrum 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-ongtrum 0.1.4
File Size Uploaded
python_ongtrum-0.1.4.tar.gz 153.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-ongtrum 0.1.4
File Interpreter ABI Platform
python_ongtrum-0.1.4-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details

Total release size: 353.7 kB

Release files / python_ongtrum-0.1.4.tar.gz

Download URL python_ongtrum-0.1.4.tar.gz
Size 153.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d2ac544de1a1ee63250b254140d1b7d44d11e8f63c62cc6eb159293c7d37c4fe
BLAKE2b-256 checksum
How to use checksums
e6b5c7f16bf1c8615b1ecc5f0ea68b663e5eb59bd819f9ee8b918a0f6875e591
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.6

Release files / python_ongtrum-0.1.4-cp312-cp312-win_amd64.whl

Download URL python_ongtrum-0.1.4-cp312-cp312-win_amd64.whl
Size 200.3 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
947e404038414427653d6347db4bc9bbf077228f6037dbbb2683359ec3ff4d35
BLAKE2b-256 checksum
How to use checksums
5c1e7b3edc31cb3afd6c05884f0a951129a8d3eccf53dd827dab51b81db2c874
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.6

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page