A Python enabled simple regression testing framework for Modelica models
Project description
MoPyRegtest: A Python enabled simple regression testing framework for Modelica models
A lightweight, CI-friendly regression testing framework for Modelica models,
wrapped in Python's unittest module.
Uses OpenModelica for model translation and simulation.
Key features:
- Regression testing — compare simulation results against reference CSV files using configurable metrics and tolerances
- Simulation-only testing — verify that models compile, build, and simulate successfully (useful for unit test models with built-in assertions)
- Automatic test generation — generate
unittesttest files for entire Modelica libraries via CLI or Python script - CSV comparison — compare two CSV result files directly from the command line
Prerequisites
- Python 3 with
numpyandpandas - OpenModelica (>= 1.13.0) with
omconPATH
Installation
# From PyPI
pip3 install --user mopyregtest
# From source
git clone https://github.com/pstelzig/MoPyRegtest.git
cd MoPyRegtest
pip3 install --user .
Verify the CLI: mopyregtest --help
Tip: If
mopyregtestis not found, check that pip's script directory is on yourPATH.
Runpip3 uninstall mopyregtest(without confirming) to see where pip installed the executable.
Quick start
Regression test (manual)
import mopyregtest
tester = mopyregtest.RegressionTest(
package_folder="~/.openmodelica/libraries/Modelica 4.0.0+maint.om",
model_in_package="Modelica.Electrical.Analog.Examples.HeatingRectifier",
result_folder="./results",
modelica_version="4.0.0")
tester.compare_result(reference_result="references/HeatingRectifier_res.csv", tol=1e-3)
tester.cleanup(ask_confirmation=False)
Simulation-only test (manual)
tester = mopyregtest.RegressionTest(
package_folder="~/.openmodelica/libraries/Modelica 4.0.0+maint.om",
model_in_package="Modelica.Blocks.Examples.Filter",
result_folder="./results")
tester.check_simulation()
tester.cleanup(ask_confirmation=False)
Auto-generate tests (CLI)
# Regression tests
mopyregtest generate ./gen_tests MyTest ~/".openmodelica/libraries/Modelica 4.0.0+maint.om/" \
Modelica.Blocks.Sources.Sine,Modelica.Blocks.Sources.Step
# Simulation-only tests
mopyregtest generate --mode=simulation ./gen_tests MySimTest ~/".openmodelica/libraries/Modelica 4.0.0+maint.om/" \
Modelica.Blocks.Examples.Filter
Compare CSV files (CLI)
mopyregtest compare --metric=Lp_dist --tol=0.015 --validated-cols=y reference.csv actual.csv
Documentation
For detailed usage, metrics reference, and worked examples see the documentation.
Runnable examples are in the examples/ folder.
License
MIT — see LICENSE.
Contributing
Contributions are welcome! Please open an issue or pull request.
Authors
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 mopyregtest-0.6.0rc1.tar.gz.
File metadata
- Download URL: mopyregtest-0.6.0rc1.tar.gz
- Upload date:
- Size: 21.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7b78d4dbaa3e3b20a50e61efae0cdc4de9d3da517dd781b8c92be7e72b16ba7
|
|
| MD5 |
b5d99b9a446a8aa54ca3e9ac8986806d
|
|
| BLAKE2b-256 |
bbee334fa9c64fb8bd922d998e11df73676e027f0a7b9fb8c95a3d2f18c83c3f
|
File details
Details for the file mopyregtest-0.6.0rc1-py3-none-any.whl.
File metadata
- Download URL: mopyregtest-0.6.0rc1-py3-none-any.whl
- Upload date:
- Size: 22.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff3b0adf822e6f306bfc72b35667358c0732e1e406164ba72b722f00f3f0c262
|
|
| MD5 |
a724f4a5a99e3d15ecaa0afdb97fc6a2
|
|
| BLAKE2b-256 |
06872928e0bd273edd2bb36cf147a74c9fa067ac3ae71b501df919925824d579
|