Ongtrum is a Python test runner designed for speed.
Project description
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
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 python_ongtrum-0.1.4.tar.gz.
File metadata
- Download URL: python_ongtrum-0.1.4.tar.gz
- Upload date:
- Size: 153.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2ac544de1a1ee63250b254140d1b7d44d11e8f63c62cc6eb159293c7d37c4fe
|
|
| MD5 |
c56ff6e0a3be692c93ce73761d9afb58
|
|
| BLAKE2b-256 |
e6b5c7f16bf1c8615b1ecc5f0ea68b663e5eb59bd819f9ee8b918a0f6875e591
|
File details
Details for the file python_ongtrum-0.1.4-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: python_ongtrum-0.1.4-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 200.3 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
947e404038414427653d6347db4bc9bbf077228f6037dbbb2683359ec3ff4d35
|
|
| MD5 |
85bdc654297f9d1c5e680565dd664f4b
|
|
| BLAKE2b-256 |
5c1e7b3edc31cb3afd6c05884f0a951129a8d3eccf53dd827dab51b81db2c874
|