MoPyRegtest 0.5.1__tar.gz → 0.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. mopyregtest-0.6.0/MoPyRegtest.egg-info/PKG-INFO +121 -0
  2. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/MoPyRegtest.egg-info/SOURCES.txt +1 -0
  3. mopyregtest-0.6.0/PKG-INFO +121 -0
  4. mopyregtest-0.6.0/README.md +96 -0
  5. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/mopyregtest/cli.py +9 -1
  6. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/mopyregtest/generator.py +50 -14
  7. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/mopyregtest/modelicaregressiontest.py +25 -0
  8. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/setup.py +1 -1
  9. mopyregtest-0.6.0/tests/test_check_success.py +46 -0
  10. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/tests/test_cli.py +30 -0
  11. mopyregtest-0.5.1/MoPyRegtest.egg-info/PKG-INFO +0 -170
  12. mopyregtest-0.5.1/PKG-INFO +0 -170
  13. mopyregtest-0.5.1/README.md +0 -154
  14. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/LICENSE +0 -0
  15. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/MoPyRegtest.egg-info/dependency_links.txt +0 -0
  16. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/MoPyRegtest.egg-info/entry_points.txt +0 -0
  17. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/MoPyRegtest.egg-info/requires.txt +0 -0
  18. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/MoPyRegtest.egg-info/top_level.txt +0 -0
  19. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/mopyregtest/__init__.py +0 -0
  20. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/mopyregtest/metrics.py +0 -0
  21. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/mopyregtest/templates/omc/model_import.mos.template +0 -0
  22. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/mopyregtest/templates/omc/model_simulate.mos.template +0 -0
  23. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/mopyregtest/utils.py +0 -0
  24. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/setup.cfg +0 -0
  25. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/tests/test_compare_results.py +0 -0
  26. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/tests/test_metrics.py +0 -0
  27. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/tests/test_modelerror.py +0 -0
  28. {mopyregtest-0.5.1 → mopyregtest-0.6.0}/tests/test_unify_timestamps.py +0 -0
@@ -0,0 +1,121 @@
1
+ Metadata-Version: 2.4
2
+ Name: MoPyRegtest
3
+ Version: 0.6.0
4
+ Summary: A Python enabled simple regression testing framework for Modelica models
5
+ Home-page: https://github.com/pstelzig/mopyregtest
6
+ Author: Philipp Emanuel Stelzig
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: Microsoft :: Windows :: Windows 10
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: numpy
15
+ Requires-Dist: pandas
16
+ Dynamic: author
17
+ Dynamic: classifier
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: home-page
21
+ Dynamic: license-file
22
+ Dynamic: requires-dist
23
+ Dynamic: requires-python
24
+ Dynamic: summary
25
+
26
+ # MoPyRegtest: A Python enabled simple regression testing framework for Modelica models
27
+
28
+ **Project status**
29
+ [![Unit tests](https://github.com/pstelzig/mopyregtest/actions/workflows/job-unit-tests.yml/badge.svg?branch=master)](https://github.com/pstelzig/MoPyRegtest/actions/workflows/job-unit-tests.yml)
30
+ [![Examples](https://github.com/pstelzig/mopyregtest/actions/workflows/job-examples.yml/badge.svg?branch=master)](https://github.com/pstelzig/MoPyRegtest/actions/workflows/job-examples.yml)
31
+ [![Example usage in other repo](https://github.com/pstelzig/mopyregtest/actions/workflows/job-example-for-other-repo.yml/badge.svg?branch=master)](https://github.com/pstelzig/MoPyRegtest/actions/workflows/job-example-for-other-repo.yml)
32
+ [![Publish to PyPI](https://github.com/pstelzig/mopyregtest/actions/workflows/pythonpublish.yml/badge.svg)](https://pypi.org/project/MoPyRegtest/)
33
+
34
+ A lightweight, CI-friendly regression testing framework for [Modelica](https://www.modelica.org/) models,
35
+ wrapped in Python's [`unittest`](https://docs.python.org/3/library/unittest.html) module.
36
+ Uses [OpenModelica](https://www.openmodelica.org/) for model translation and simulation.
37
+
38
+ **Key features:**
39
+ - **Regression testing** — compare simulation results against reference CSV files using configurable metrics and tolerances
40
+ - **Success-only testing** — verify that models compile, build, and simulate successfully (useful for unit test models with built-in assertions)
41
+ - **Automatic test generation** — generate `unittest` test files for entire Modelica libraries via CLI or Python script
42
+ - **CSV comparison** — compare two CSV result files directly from the command line
43
+
44
+ ## Prerequisites
45
+ - [Python 3](https://www.python.org/) with [`numpy`](https://numpy.org/) and [`pandas`](https://pandas.pydata.org/)
46
+ - [OpenModelica](https://www.openmodelica.org/) (>= 1.13.0) with `omc` on `PATH`
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ # From PyPI
52
+ python3 -m pip install --user mopyregtest
53
+
54
+ # From source
55
+ git clone https://github.com/pstelzig/MoPyRegtest.git
56
+ cd MoPyRegtest
57
+ python3 -m pip install --user .
58
+ ```
59
+
60
+ Verify the CLI: `mopyregtest --help`
61
+
62
+ > **Tip:** If `mopyregtest` is not found, check that pip's script directory is on your `PATH`.
63
+ > Run `python3 -m pip uninstall mopyregtest` (without confirming) to see where pip installed the executable.
64
+
65
+ ## Quick start
66
+
67
+ ### Regression test (manual)
68
+
69
+ ```python
70
+ import mopyregtest
71
+
72
+ tester = mopyregtest.RegressionTest(
73
+ package_folder="~/.openmodelica/libraries/Modelica 4.0.0+maint.om",
74
+ model_in_package="Modelica.Electrical.Analog.Examples.HeatingRectifier",
75
+ result_folder="./results",
76
+ modelica_version="4.0.0")
77
+
78
+ tester.compare_result(reference_result="references/HeatingRectifier_res.csv", tol=1e-3)
79
+ ```
80
+
81
+ ### Success-only test (manual)
82
+
83
+ ```python
84
+ tester = mopyregtest.RegressionTest(
85
+ package_folder="~/.openmodelica/libraries/Modelica 4.0.0+maint.om",
86
+ model_in_package="Modelica.Blocks.Examples.Filter",
87
+ result_folder="./results")
88
+
89
+ tester.check_success()
90
+ ```
91
+
92
+ ### Auto-generate tests (CLI)
93
+
94
+ ```bash
95
+ # Regression tests
96
+ mopyregtest generate ./gen_tests MyTest ~/".openmodelica/libraries/Modelica 4.0.0+maint.om/" \
97
+ Modelica.Blocks.Sources.Sine,Modelica.Blocks.Sources.Step
98
+
99
+ # Success-only tests
100
+ mopyregtest generate --mode=success ./gen_tests MySimTest ~/".openmodelica/libraries/Modelica 4.0.0+maint.om/" \
101
+ Modelica.Blocks.Examples.Filter
102
+ ```
103
+
104
+ ### Compare CSV files (CLI)
105
+
106
+ ```bash
107
+ mopyregtest compare --metric=Lp_dist --tol=0.015 --validated-cols=y reference.csv actual.csv
108
+ ```
109
+
110
+ ## Documentation
111
+ For detailed usage, metrics reference, and worked examples see the [documentation](doc/usage.md).
112
+ Runnable examples are in the [examples/](examples/) folder.
113
+
114
+ ## License
115
+ MIT — see [LICENSE](LICENSE).
116
+
117
+ ## Contributing
118
+ Contributions are welcome! Please open an issue or pull request.
119
+
120
+ ## Authors
121
+ - [Dr. Philipp Emanuel Stelzig](https://github.com/pstelzig)
@@ -15,6 +15,7 @@ mopyregtest/modelicaregressiontest.py
15
15
  mopyregtest/utils.py
16
16
  mopyregtest/templates/omc/model_import.mos.template
17
17
  mopyregtest/templates/omc/model_simulate.mos.template
18
+ tests/test_check_success.py
18
19
  tests/test_cli.py
19
20
  tests/test_compare_results.py
20
21
  tests/test_metrics.py
@@ -0,0 +1,121 @@
1
+ Metadata-Version: 2.4
2
+ Name: MoPyRegtest
3
+ Version: 0.6.0
4
+ Summary: A Python enabled simple regression testing framework for Modelica models
5
+ Home-page: https://github.com/pstelzig/mopyregtest
6
+ Author: Philipp Emanuel Stelzig
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: Microsoft :: Windows :: Windows 10
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: numpy
15
+ Requires-Dist: pandas
16
+ Dynamic: author
17
+ Dynamic: classifier
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: home-page
21
+ Dynamic: license-file
22
+ Dynamic: requires-dist
23
+ Dynamic: requires-python
24
+ Dynamic: summary
25
+
26
+ # MoPyRegtest: A Python enabled simple regression testing framework for Modelica models
27
+
28
+ **Project status**
29
+ [![Unit tests](https://github.com/pstelzig/mopyregtest/actions/workflows/job-unit-tests.yml/badge.svg?branch=master)](https://github.com/pstelzig/MoPyRegtest/actions/workflows/job-unit-tests.yml)
30
+ [![Examples](https://github.com/pstelzig/mopyregtest/actions/workflows/job-examples.yml/badge.svg?branch=master)](https://github.com/pstelzig/MoPyRegtest/actions/workflows/job-examples.yml)
31
+ [![Example usage in other repo](https://github.com/pstelzig/mopyregtest/actions/workflows/job-example-for-other-repo.yml/badge.svg?branch=master)](https://github.com/pstelzig/MoPyRegtest/actions/workflows/job-example-for-other-repo.yml)
32
+ [![Publish to PyPI](https://github.com/pstelzig/mopyregtest/actions/workflows/pythonpublish.yml/badge.svg)](https://pypi.org/project/MoPyRegtest/)
33
+
34
+ A lightweight, CI-friendly regression testing framework for [Modelica](https://www.modelica.org/) models,
35
+ wrapped in Python's [`unittest`](https://docs.python.org/3/library/unittest.html) module.
36
+ Uses [OpenModelica](https://www.openmodelica.org/) for model translation and simulation.
37
+
38
+ **Key features:**
39
+ - **Regression testing** — compare simulation results against reference CSV files using configurable metrics and tolerances
40
+ - **Success-only testing** — verify that models compile, build, and simulate successfully (useful for unit test models with built-in assertions)
41
+ - **Automatic test generation** — generate `unittest` test files for entire Modelica libraries via CLI or Python script
42
+ - **CSV comparison** — compare two CSV result files directly from the command line
43
+
44
+ ## Prerequisites
45
+ - [Python 3](https://www.python.org/) with [`numpy`](https://numpy.org/) and [`pandas`](https://pandas.pydata.org/)
46
+ - [OpenModelica](https://www.openmodelica.org/) (>= 1.13.0) with `omc` on `PATH`
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ # From PyPI
52
+ python3 -m pip install --user mopyregtest
53
+
54
+ # From source
55
+ git clone https://github.com/pstelzig/MoPyRegtest.git
56
+ cd MoPyRegtest
57
+ python3 -m pip install --user .
58
+ ```
59
+
60
+ Verify the CLI: `mopyregtest --help`
61
+
62
+ > **Tip:** If `mopyregtest` is not found, check that pip's script directory is on your `PATH`.
63
+ > Run `python3 -m pip uninstall mopyregtest` (without confirming) to see where pip installed the executable.
64
+
65
+ ## Quick start
66
+
67
+ ### Regression test (manual)
68
+
69
+ ```python
70
+ import mopyregtest
71
+
72
+ tester = mopyregtest.RegressionTest(
73
+ package_folder="~/.openmodelica/libraries/Modelica 4.0.0+maint.om",
74
+ model_in_package="Modelica.Electrical.Analog.Examples.HeatingRectifier",
75
+ result_folder="./results",
76
+ modelica_version="4.0.0")
77
+
78
+ tester.compare_result(reference_result="references/HeatingRectifier_res.csv", tol=1e-3)
79
+ ```
80
+
81
+ ### Success-only test (manual)
82
+
83
+ ```python
84
+ tester = mopyregtest.RegressionTest(
85
+ package_folder="~/.openmodelica/libraries/Modelica 4.0.0+maint.om",
86
+ model_in_package="Modelica.Blocks.Examples.Filter",
87
+ result_folder="./results")
88
+
89
+ tester.check_success()
90
+ ```
91
+
92
+ ### Auto-generate tests (CLI)
93
+
94
+ ```bash
95
+ # Regression tests
96
+ mopyregtest generate ./gen_tests MyTest ~/".openmodelica/libraries/Modelica 4.0.0+maint.om/" \
97
+ Modelica.Blocks.Sources.Sine,Modelica.Blocks.Sources.Step
98
+
99
+ # Success-only tests
100
+ mopyregtest generate --mode=success ./gen_tests MySimTest ~/".openmodelica/libraries/Modelica 4.0.0+maint.om/" \
101
+ Modelica.Blocks.Examples.Filter
102
+ ```
103
+
104
+ ### Compare CSV files (CLI)
105
+
106
+ ```bash
107
+ mopyregtest compare --metric=Lp_dist --tol=0.015 --validated-cols=y reference.csv actual.csv
108
+ ```
109
+
110
+ ## Documentation
111
+ For detailed usage, metrics reference, and worked examples see the [documentation](doc/usage.md).
112
+ Runnable examples are in the [examples/](examples/) folder.
113
+
114
+ ## License
115
+ MIT — see [LICENSE](LICENSE).
116
+
117
+ ## Contributing
118
+ Contributions are welcome! Please open an issue or pull request.
119
+
120
+ ## Authors
121
+ - [Dr. Philipp Emanuel Stelzig](https://github.com/pstelzig)
@@ -0,0 +1,96 @@
1
+ # MoPyRegtest: A Python enabled simple regression testing framework for Modelica models
2
+
3
+ **Project status**
4
+ [![Unit tests](https://github.com/pstelzig/mopyregtest/actions/workflows/job-unit-tests.yml/badge.svg?branch=master)](https://github.com/pstelzig/MoPyRegtest/actions/workflows/job-unit-tests.yml)
5
+ [![Examples](https://github.com/pstelzig/mopyregtest/actions/workflows/job-examples.yml/badge.svg?branch=master)](https://github.com/pstelzig/MoPyRegtest/actions/workflows/job-examples.yml)
6
+ [![Example usage in other repo](https://github.com/pstelzig/mopyregtest/actions/workflows/job-example-for-other-repo.yml/badge.svg?branch=master)](https://github.com/pstelzig/MoPyRegtest/actions/workflows/job-example-for-other-repo.yml)
7
+ [![Publish to PyPI](https://github.com/pstelzig/mopyregtest/actions/workflows/pythonpublish.yml/badge.svg)](https://pypi.org/project/MoPyRegtest/)
8
+
9
+ A lightweight, CI-friendly regression testing framework for [Modelica](https://www.modelica.org/) models,
10
+ wrapped in Python's [`unittest`](https://docs.python.org/3/library/unittest.html) module.
11
+ Uses [OpenModelica](https://www.openmodelica.org/) for model translation and simulation.
12
+
13
+ **Key features:**
14
+ - **Regression testing** — compare simulation results against reference CSV files using configurable metrics and tolerances
15
+ - **Success-only testing** — verify that models compile, build, and simulate successfully (useful for unit test models with built-in assertions)
16
+ - **Automatic test generation** — generate `unittest` test files for entire Modelica libraries via CLI or Python script
17
+ - **CSV comparison** — compare two CSV result files directly from the command line
18
+
19
+ ## Prerequisites
20
+ - [Python 3](https://www.python.org/) with [`numpy`](https://numpy.org/) and [`pandas`](https://pandas.pydata.org/)
21
+ - [OpenModelica](https://www.openmodelica.org/) (>= 1.13.0) with `omc` on `PATH`
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ # From PyPI
27
+ python3 -m pip install --user mopyregtest
28
+
29
+ # From source
30
+ git clone https://github.com/pstelzig/MoPyRegtest.git
31
+ cd MoPyRegtest
32
+ python3 -m pip install --user .
33
+ ```
34
+
35
+ Verify the CLI: `mopyregtest --help`
36
+
37
+ > **Tip:** If `mopyregtest` is not found, check that pip's script directory is on your `PATH`.
38
+ > Run `python3 -m pip uninstall mopyregtest` (without confirming) to see where pip installed the executable.
39
+
40
+ ## Quick start
41
+
42
+ ### Regression test (manual)
43
+
44
+ ```python
45
+ import mopyregtest
46
+
47
+ tester = mopyregtest.RegressionTest(
48
+ package_folder="~/.openmodelica/libraries/Modelica 4.0.0+maint.om",
49
+ model_in_package="Modelica.Electrical.Analog.Examples.HeatingRectifier",
50
+ result_folder="./results",
51
+ modelica_version="4.0.0")
52
+
53
+ tester.compare_result(reference_result="references/HeatingRectifier_res.csv", tol=1e-3)
54
+ ```
55
+
56
+ ### Success-only test (manual)
57
+
58
+ ```python
59
+ tester = mopyregtest.RegressionTest(
60
+ package_folder="~/.openmodelica/libraries/Modelica 4.0.0+maint.om",
61
+ model_in_package="Modelica.Blocks.Examples.Filter",
62
+ result_folder="./results")
63
+
64
+ tester.check_success()
65
+ ```
66
+
67
+ ### Auto-generate tests (CLI)
68
+
69
+ ```bash
70
+ # Regression tests
71
+ mopyregtest generate ./gen_tests MyTest ~/".openmodelica/libraries/Modelica 4.0.0+maint.om/" \
72
+ Modelica.Blocks.Sources.Sine,Modelica.Blocks.Sources.Step
73
+
74
+ # Success-only tests
75
+ mopyregtest generate --mode=success ./gen_tests MySimTest ~/".openmodelica/libraries/Modelica 4.0.0+maint.om/" \
76
+ Modelica.Blocks.Examples.Filter
77
+ ```
78
+
79
+ ### Compare CSV files (CLI)
80
+
81
+ ```bash
82
+ mopyregtest compare --metric=Lp_dist --tol=0.015 --validated-cols=y reference.csv actual.csv
83
+ ```
84
+
85
+ ## Documentation
86
+ For detailed usage, metrics reference, and worked examples see the [documentation](doc/usage.md).
87
+ Runnable examples are in the [examples/](examples/) folder.
88
+
89
+ ## License
90
+ MIT — see [LICENSE](LICENSE).
91
+
92
+ ## Contributing
93
+ Contributions are welcome! Please open an issue or pull request.
94
+
95
+ ## Authors
96
+ - [Dr. Philipp Emanuel Stelzig](https://github.com/pstelzig)
@@ -34,6 +34,7 @@ def generate(args):
34
34
  result_folder = "results"
35
35
  package_folder = args.package_folder
36
36
  models_in_package = args.models_in_package.split(",")
37
+ mode = args.mode
37
38
 
38
39
  if args.references is not None:
39
40
  ref_pairs = args.references.split(",")
@@ -54,7 +55,8 @@ def generate(args):
54
55
  if args.metric is not None:
55
56
  metric = metric_str_to_func(args.metric)
56
57
 
57
- gen = Generator(package_folder=package_folder, models_in_package=models_in_package, metric=metric, tol=args.tol)
58
+ gen = Generator(package_folder=package_folder, models_in_package=models_in_package,
59
+ mode=mode, metric=metric, tol=args.tol)
58
60
  gen.generate_tests(test_folder, test_name, result_folder, references)
59
61
 
60
62
  return
@@ -99,6 +101,12 @@ def parse_args(cmd_args):
99
101
  generate_parser.add_argument("models_in_package", type=str,
100
102
  help="Comma separated list of model names like <model name1>,<model name2> "
101
103
  "to be turned into regression tests")
104
+ generate_parser.add_argument("--mode", type=str,
105
+ help="Testing mode. 'regression' (default) generates tests that compare simulation "
106
+ "results against reference CSV files. 'success' generates tests that only "
107
+ "check whether the model simulates successfully, without reference comparison.",
108
+ choices=["regression", "success"],
109
+ default="regression")
102
110
  generate_parser.add_argument("--metric", type=str,
103
111
  help="Metric to be used. Choose here from predefined values. "
104
112
  "For user-defined metrics please consider creating the tests with a dedicated script. "
@@ -71,6 +71,24 @@ class Test$$CLASS_NAME$$(unittest.TestCase):
71
71
  return
72
72
  """
73
73
 
74
+ METHOD_CHECK_SUCCESS = \
75
+ """
76
+ def test_$$METHOD_NAME$$(self):
77
+ tester = mopyregtest.RegressionTest(package_folder="$$PACKAGE_FOLDER$$",
78
+ model_in_package="$$MODEL_IN_PACKAGE$$",
79
+ result_folder="$$RESULT_FOLDER$$",
80
+ modelica_version="$$MODELICA_VERSION$$",
81
+ dependencies=$$DEPENDENCIES$$)
82
+
83
+ # Check that simulation completes successfully
84
+ tester.check_success()
85
+
86
+ # Deletes result_folder after it has been created. Leave out if you feel uncomfortable with auto-deletion!
87
+ $$DO_CLEANUP$$tester.cleanup()
88
+
89
+ return
90
+ """
91
+
74
92
  MAIN_STATEMENT = \
75
93
  """
76
94
  if __name__ == '__main__':
@@ -78,6 +96,7 @@ if __name__ == '__main__':
78
96
  """
79
97
 
80
98
  def __init__(self, package_folder, models_in_package, modelica_version="default", dependencies=None,
99
+ mode="regression",
81
100
  metric=metrics.norm_infty_dist,
82
101
  tol=1e-7, unify_timestamps=True, fill_in_method="ffill"):
83
102
  """
@@ -95,6 +114,10 @@ if __name__ == '__main__':
95
114
  Optional list of strings with names of packages that the package to be tested depends on.
96
115
  Each dependency must point to the .mo file that defines the dependency. E.g. if the
97
116
  dependency is an entire package, it must be the path to the respective package's package.mo.
117
+ mode : str
118
+ Testing mode. "regression" (default) generates tests that compare simulation results against
119
+ reference CSV files. "success" generates tests that only check whether the model compiles,
120
+ builds, and simulates successfully, without any reference comparison.
98
121
  metric : function or str
99
122
  Metric to be used in result comparison. Important: If the metric is given as a funtion, one must use one
100
123
  of the predefined metrics, i.e. mopyregtest.metrics.norm_p_dist, mopyregtest.metrics.norm_infty_dist,
@@ -123,6 +146,11 @@ if __name__ == '__main__':
123
146
  self.models_in_package = models_in_package
124
147
  self.modelica_version = modelica_version
125
148
  self.dependencies = dependencies
149
+
150
+ if mode not in ["regression", "success"]:
151
+ raise ValueError(f"Invalid mode '{mode}'. Must be 'regression' or 'success'.")
152
+ self.mode = mode
153
+
126
154
  if (callable(metric) and
127
155
  metric in [metrics.norm_p_dist, metrics.norm_infty_dist,
128
156
  metrics.Lp_dist, metrics.Linfty_dist,
@@ -234,8 +262,10 @@ if __name__ == '__main__':
234
262
  test_folder = pathlib.Path(test_folder)
235
263
  if not test_folder.exists():
236
264
  test_folder.mkdir(parents=True, exist_ok=False)
237
- if not (test_folder / "references").exists():
238
- (test_folder / "references").mkdir()
265
+
266
+ if self.mode == "regression":
267
+ if not (test_folder / "references").exists():
268
+ (test_folder / "references").mkdir()
239
269
 
240
270
  # Creating the MoPyRegtest test definition
241
271
  tfile = open(pathlib.Path(test_folder) / f"test_{test_name.lower()}.py", 'w')
@@ -245,12 +275,13 @@ if __name__ == '__main__':
245
275
 
246
276
  # Creating a test method for every element in self.models_in_package
247
277
  for md in self.models_in_package:
248
- r_ref_relpath = f"references/{md}_res.csv"
249
- if (references is None or md not in references.keys()) and generate_missing_refs:
250
- self._generate_reference(reference_folder=test_folder / "references",
251
- model_in_package=md, do_cleanup=cleanup_ref_gen)
252
- else:
253
- shutil.copyfile(references[md], str(test_folder / r_ref_relpath))
278
+ if self.mode == "regression":
279
+ r_ref_relpath = f"references/{md}_res.csv"
280
+ if (references is None or md not in references.keys()) and generate_missing_refs:
281
+ self._generate_reference(reference_folder=test_folder / "references",
282
+ model_in_package=md, do_cleanup=cleanup_ref_gen)
283
+ else:
284
+ shutil.copyfile(references[md], str(test_folder / r_ref_relpath))
254
285
 
255
286
  # If the package path is relative, compute its relative path to the target test folder
256
287
  if not pathlib.PurePath(test_folder).is_absolute():
@@ -273,15 +304,20 @@ if __name__ == '__main__':
273
304
  "$$RESULT_FOLDER$$": str(pathlib.Path(test_results_folder).as_posix()),
274
305
  "$$MODELICA_VERSION$$": self.modelica_version,
275
306
  "$$DEPENDENCIES$$": dependencies_str,
276
- "$$REFERENCE_RESULT$$": str(pathlib.Path(r_ref_relpath).as_posix()),
277
- "$$METRIC$$": self.metric,
278
- "$$TOLERANCE$$": str(self.tol),
279
- "$$UNIFY_TIMESTAMPS$$": str(self.unify_timestamps),
280
- "$$FILL_IN_METHOD$$": self.fill_in_method,
281
307
  "$$DO_CLEANUP$$": "" if cleanup_in_tests else "#"
282
308
  }
283
309
 
284
- test_method = utils.replace_in_str(Generator.METHOD, repl_dict)
310
+ if self.mode == "regression":
311
+ repl_dict["$$REFERENCE_RESULT$$"] = str(pathlib.Path(r_ref_relpath).as_posix())
312
+ repl_dict["$$METRIC$$"] = self.metric
313
+ repl_dict["$$TOLERANCE$$"] = str(self.tol)
314
+ repl_dict["$$UNIFY_TIMESTAMPS$$"] = str(self.unify_timestamps)
315
+ repl_dict["$$FILL_IN_METHOD$$"] = self.fill_in_method
316
+ template = Generator.METHOD
317
+ else:
318
+ template = Generator.METHOD_CHECK_SUCCESS
319
+
320
+ test_method = utils.replace_in_str(template, repl_dict)
285
321
  tfile.write(test_method)
286
322
  tfile.flush()
287
323
 
@@ -317,6 +317,31 @@ class RegressionTest:
317
317
 
318
318
  return
319
319
 
320
+ def check_success(self):
321
+ """
322
+ Executes the simulation of the Modelica model specified in the constructor and checks that it
323
+ completes successfully. No comparison against a reference result is performed.
324
+
325
+ This is useful for Modelica libraries that have a battery of unit tests where the models contain
326
+ built-in assertions, and the user only needs to verify that the model compiles, builds, and
327
+ simulates without error.
328
+
329
+ Raises AssertionError if the simulation binary or result CSV file is not produced.
330
+
331
+ Returns
332
+ -------
333
+ out : None
334
+ """
335
+ print("\nChecking success of model {}".format(self.model_in_package))
336
+
337
+ self._import_and_simulate()
338
+
339
+ simulation_result = str(self.result_folder_path / self.model_in_package) + "_res.csv"
340
+ print("Simulation of model {} completed successfully. Result at {}".format(
341
+ self.model_in_package, simulation_result))
342
+
343
+ return
344
+
320
345
  def compare_result(self, reference_result, tol=1e-7, validated_cols=[],
321
346
  metric=metrics.norm_infty_dist,
322
347
  unify_timestamps=True, fill_in_method="ffill", write_comparison=True):
@@ -8,7 +8,7 @@ with open("README.md") as fh:
8
8
 
9
9
  setuptools.setup(
10
10
  name="MoPyRegtest",
11
- version="0.5.1",
11
+ version="0.6.0",
12
12
  author="Philipp Emanuel Stelzig",
13
13
  description="A Python enabled simple regression testing framework for Modelica models",
14
14
  long_description=long_description,
@@ -0,0 +1,46 @@
1
+ import os
2
+ import unittest
3
+ import pathlib
4
+ import mopyregtest
5
+
6
+ this_folder = pathlib.Path(__file__).absolute().parent
7
+ initial_cwd = os.getcwd()
8
+
9
+ class TestCheckSuccess(unittest.TestCase):
10
+ def test_check_success(self):
11
+ """
12
+ Test that check_success passes for a model that builds and simulates.
13
+ DoesNotFinish builds and produces a result CSV, even though it does not reach
14
+ the simulation end time. check_success should succeed because a result is produced.
15
+ """
16
+ os.chdir(initial_cwd)
17
+
18
+ tester = mopyregtest.RegressionTest(package_folder=this_folder / "data/FlawedModels",
19
+ model_in_package="FlawedModels.DoesNotFinish",
20
+ result_folder=this_folder / "data/FlawedModels/results")
21
+
22
+ tester.check_success()
23
+
24
+ tester.cleanup(ask_confirmation=False)
25
+
26
+ return
27
+
28
+ def test_check_success_build_failure(self):
29
+ """
30
+ Test that check_success raises AssertionError for a model that does not build.
31
+ """
32
+ os.chdir(initial_cwd)
33
+
34
+ tester = mopyregtest.RegressionTest(package_folder=this_folder / "data/FlawedModels",
35
+ model_in_package="FlawedModels.DoesNotBuild",
36
+ result_folder=this_folder / "data/FlawedModels/results")
37
+
38
+ self.assertRaises(AssertionError, tester.check_success)
39
+
40
+ tester.cleanup(ask_confirmation=False)
41
+
42
+ return
43
+
44
+
45
+ if __name__ == '__main__':
46
+ unittest.main()
@@ -92,6 +92,36 @@ class TestCli(unittest.TestCase):
92
92
 
93
93
  return
94
94
 
95
+ def test_generate_success_mode(self):
96
+ """
97
+ Testing --mode=success in CLI: mopyregtest generate
98
+ Verifies that generated test file uses check_success() and no references folder is created.
99
+ """
100
+ gentests_folder = this_folder / "data/gentests_simmode"
101
+ cmd_args = ["generate",
102
+ "--mode=success",
103
+ str(gentests_folder),
104
+ "FlawedModels_SimCheck",
105
+ str(this_folder / "data/FlawedModels"),
106
+ "FlawedModels.DoesNotFinish"]
107
+
108
+ cli.parse_args(cmd_args)
109
+
110
+ # Verify the generated test file contains check_success and not compare_result
111
+ generated_file = gentests_folder / "test_flawedmodels_simcheck.py"
112
+ self.assertTrue(generated_file.exists())
113
+ content = generated_file.read_text()
114
+ self.assertIn("check_success()", content)
115
+ self.assertNotIn("compare_result(", content)
116
+
117
+ # Verify no references folder was created
118
+ self.assertFalse((gentests_folder / "references").exists())
119
+
120
+ # Clean up
121
+ shutil.rmtree(gentests_folder)
122
+
123
+ return
124
+
95
125
  def test_compare1(self):
96
126
  """
97
127
  Testing for default arguments in CLI: mopyregtest compare
@@ -1,170 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: MoPyRegtest
3
- Version: 0.5.1
4
- Summary: A Python enabled simple regression testing framework for Modelica models
5
- Home-page: https://github.com/pstelzig/mopyregtest
6
- Author: Philipp Emanuel Stelzig
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: Microsoft :: Windows :: Windows 10
10
- Classifier: Operating System :: POSIX :: Linux
11
- Requires-Python: >=3.8
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
- Requires-Dist: numpy
15
- Requires-Dist: pandas
16
-
17
- # MoPyRegtest: A Python enabled simple regression testing framework for Modelica models
18
-
19
- **General**
20
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/pstelzig/MoPyRegtest/tree/master/LICENSE)
21
- [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/pstelzig/MoPyRegtest/issues)
22
-
23
- **Project status**
24
- [![Unit tests](https://github.com/pstelzig/mopyregtest/actions/workflows/job-unit-tests.yml/badge.svg?branch=master)](https://github.com/pstelzig/MoPyRegtest/actions/workflows/job-unit-tests.yml)
25
- [![Examples](https://github.com/pstelzig/mopyregtest/actions/workflows/job-examples.yml/badge.svg?branch=master)](https://github.com/pstelzig/MoPyRegtest/actions/workflows/job-examples.yml)
26
- [![Example usage in other repo](https://github.com/pstelzig/mopyregtest/actions/workflows/job-example-for-other-repo.yml/badge.svg?branch=master)](https://github.com/pstelzig/MoPyRegtest/actions/workflows/job-example-for-other-repo.yml)
27
- [![Publish to PyPI](https://github.com/pstelzig/mopyregtest/actions/workflows/pythonpublish.yml/badge.svg)](https://pypi.org/project/MoPyRegtest/)
28
-
29
- Scope of this project is to
30
- * provide a simple regression testing framework for Modelica models
31
- * support continuous integration (CI) for Modelica library development, in particular
32
- * test for reproducibility of results from [Modelica](https://www.modelica.org/) models and to
33
- * have it wrapped in the well-known [Python `unittest` module](https://docs.python.org/3/library/unittest.html)
34
-
35
- ## Background:
36
- When developing Modelica models or libraries and releases have been made, there is definitely the need for testing. E.g.
37
- - validation of successful model translation,
38
- - reproducibility of simulation results, or
39
- - making sure refactorings in Modelica libraries do not alter the behavior.
40
-
41
- Other testing criteria could be memory consumption, CPU time and more.
42
-
43
- ## Why MoPyRegtest
44
- The scope of MoPyRegtest is to have a lightweight and simple way to perform regression tests and to be able to integrate
45
- this with automated testing and continuous integration (CI) toolchains, like e.g. GitHub Actions.
46
- Without immediately requiring commercial simulation tools or creating strong dependencies from other Modelica libraries.
47
-
48
- All that is needed to use MoPyRegtest is a Python 3 installation, an [OpenModelica](https://www.openmodelica.org/) installation,
49
- and a text editor.
50
-
51
- ## Current realization
52
- The current realization uses the [Python `unittest` module](https://docs.python.org/3/library/unittest.html) and calls the [OpenModelica compiler `omc`](https://openmodelica.org/) as an
53
- external executable for translation and simulation of Modelica models. Note that the implementation of MoPyRegtest is not
54
- specific to OpenModelica but can be replaced by any other Modelica simulation tool that comes with a suitable scripting API.
55
-
56
- The test execution and orchestration is done by the Python `unittest` module. In particular, Python `unittest` supports
57
- [test discovery](https://docs.python.org/3/library/unittest.html#test-discovery).
58
- Also, `unittest` is a standard module that comes with virtually all Python distributions.
59
-
60
- **MoPyRegtest is work in progress!**
61
-
62
- ## Usage and example
63
- With MoPyRegtest, users can define regression tests manually in Python for one Modelica model at a time,
64
- or automatically for many Modelica models simultaneously.
65
-
66
- ### Manual test case definition
67
- The user has to
68
- * provide Modelica models that can be translated, built and executed and produce a result `.csv` file
69
- * provide for every Modelica model a `.csv` file with a reference result against which an actual result is compared
70
- * create a Python file and test methods that instantiate a `mopyregtest.RegressionTest` object,
71
- which needs to know which Modelica model to test and where to find the reference result.
72
-
73
- Examples can be found in the `examples` folder. Also see the [examples/README.md](https://github.com/pstelzig/MoPyRegtest/tree/master/examples/README.md).
74
-
75
- ### Automatic test case generation
76
- MoPyRegtest can generate regression test definitions for elements of a Modelica library automatically.
77
- Either by creating [Generator class objects](https://github.com/pstelzig/MoPyRegtest/tree/master/mopyregtest/generator.py). Or using the
78
- [`mopyregtest` command line tool](https://github.com/pstelzig/MoPyRegtest/blob/master/mopyregtest/cli.py).
79
-
80
- The folder [examples/generate_tests/README.md](https://github.com/pstelzig/MoPyRegtest/tree/master/examples/generate_tests/README.md)
81
- has a detailed explanation on how to automatically generate tests.
82
-
83
- ## Prerequisites
84
- To use MoPyRegtest you need to have
85
- * a [Python 3](https://www.python.org/) distribution including the modules [`unittest`](https://docs.python.org/3/library/unittest.html), [`numpy`](https://numpy.org/) and [`pandas`](https://pandas.pydata.org/),
86
- * a working [OpenModelica](https://www.openmodelica.org/) installation (version 1.13.0 or later, works also for latest 1.22), and
87
- * the OpenModelica compiler executable `omc` must be accessible via the `PATH` variable.
88
-
89
- ## Installation using pip3
90
- It is most convenient to install MoPyRegtest using [Python's package manager `pip`](https://packaging.python.org/tutorials/installing-packages/).
91
- MoPyRegtest *does not need any special privileges* to run.
92
-
93
- ### Install from PyPI
94
- You can install MoPyRegtest from the [Python Package Index](https://pypi.org/project/MoPyRegtest/) by running
95
-
96
- ```bash
97
- pip3 install --user mopyregtest
98
- ```
99
-
100
- To install a specific version, e.g. `v0.3.1`, run `pip3 install --user mopyregtest==0.3.1`
101
-
102
- ### Install from source
103
- To install from source, first clone this repository to your local `<your-mopyregtest-dir>` (adapt to your needs) with
104
- the command `git clone https://github.com/pstelzig/MoPyRegtest.git <your-mopyregtest-dir>`
105
-
106
- Then run
107
-
108
- ```bash
109
- cd <your-mopyregtest-dir>
110
- pip3 install --user .
111
- ```
112
-
113
- to get the latest development head. To install a specific version from source, e.g. `v0.3.1`, run
114
-
115
- ```bash
116
- cd <your-mopyregtest-dir>
117
- git checkout v0.3.1
118
- pip3 install --user .
119
- ```
120
-
121
- ### Uninstall
122
- To uninstall MoPyRegtest, run
123
- ```bash
124
- pip3 uninstall mopyregtest
125
- ```
126
-
127
- ### Troubleshooting
128
-
129
- #### Problem: CLI `mopyregtest` cannot be found
130
- To check if MoPyRegtest's command line tool is working, run `mopyregtest --help` from a terminal.
131
-
132
- If an error message shows that the program `mopyregtest` cannot be found, then you have to check if your PATH variable
133
- knows where to find `mopyregtest` as installed by pip. To find out the location, run `pip uninstall mopyregtest` but do
134
- not confirm to proceed. The uninstallation will tell you which files pip would remove upon uninstalling MoPyRegtest,
135
- including the `mopyregtest` executable (or `mopyregtest.exe` under Windows) and its location.
136
-
137
- ```
138
- Found existing installation: MoPyRegtest 0.4.0rc1
139
- Uninstalling MoPyRegtest-0.4.0rc1:
140
- Would remove:
141
- /home/<your user name>/.local/bin/mopyregtest
142
- /home/<your user name>/.local/lib/python3.10/site-packages/MoPyRegtest-0.4.0rc1.dist-info/*
143
- /home/<your user name>/.local/lib/python3.10/site-packages/mopyregtest/*
144
- Proceed (Y/n)?
145
- ```
146
-
147
- Then, one could either call `mopyregtest` with its full path, or one could add its parent folder to the PATH
148
- variable (Be careful! First make sure that this does not cause any harm to your system).
149
-
150
- ## Future Work
151
- * Allow for parallel execution of regression tests
152
- * Improve readability of in particular failed test results
153
- * Provide logs that help users in the analysis of failed tests
154
- * Make definition of the tests even simpler, e.g. using a more human-readable BDD approach
155
-
156
- ## Open source software used
157
- MoPyRegtest is implemented in Python3 and uses the Python core modules (including `pathlib` and `unittest`) along with
158
- [`numpy`](https://numpy.org/) and [`pandas`](https://pandas.pydata.org/).
159
-
160
- # License
161
- MoPyRegtest is open source software. MoPyRegtest is provided "as is", without warranty of any kind.
162
- Usage is completely at your own risk. See the file `LICENSE`.
163
-
164
- # How to contribute
165
- If you want to help me extend MoPyRegtest, please drop me a message! Contributions are welcome!
166
-
167
- # Authors
168
- The MoPyRegtest is being developed by the following authors:
169
- * [Dr. Philipp Emanuel Stelzig](https://github.com/pstelzig)
170
-
@@ -1,170 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: MoPyRegtest
3
- Version: 0.5.1
4
- Summary: A Python enabled simple regression testing framework for Modelica models
5
- Home-page: https://github.com/pstelzig/mopyregtest
6
- Author: Philipp Emanuel Stelzig
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: Microsoft :: Windows :: Windows 10
10
- Classifier: Operating System :: POSIX :: Linux
11
- Requires-Python: >=3.8
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
- Requires-Dist: numpy
15
- Requires-Dist: pandas
16
-
17
- # MoPyRegtest: A Python enabled simple regression testing framework for Modelica models
18
-
19
- **General**
20
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/pstelzig/MoPyRegtest/tree/master/LICENSE)
21
- [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/pstelzig/MoPyRegtest/issues)
22
-
23
- **Project status**
24
- [![Unit tests](https://github.com/pstelzig/mopyregtest/actions/workflows/job-unit-tests.yml/badge.svg?branch=master)](https://github.com/pstelzig/MoPyRegtest/actions/workflows/job-unit-tests.yml)
25
- [![Examples](https://github.com/pstelzig/mopyregtest/actions/workflows/job-examples.yml/badge.svg?branch=master)](https://github.com/pstelzig/MoPyRegtest/actions/workflows/job-examples.yml)
26
- [![Example usage in other repo](https://github.com/pstelzig/mopyregtest/actions/workflows/job-example-for-other-repo.yml/badge.svg?branch=master)](https://github.com/pstelzig/MoPyRegtest/actions/workflows/job-example-for-other-repo.yml)
27
- [![Publish to PyPI](https://github.com/pstelzig/mopyregtest/actions/workflows/pythonpublish.yml/badge.svg)](https://pypi.org/project/MoPyRegtest/)
28
-
29
- Scope of this project is to
30
- * provide a simple regression testing framework for Modelica models
31
- * support continuous integration (CI) for Modelica library development, in particular
32
- * test for reproducibility of results from [Modelica](https://www.modelica.org/) models and to
33
- * have it wrapped in the well-known [Python `unittest` module](https://docs.python.org/3/library/unittest.html)
34
-
35
- ## Background:
36
- When developing Modelica models or libraries and releases have been made, there is definitely the need for testing. E.g.
37
- - validation of successful model translation,
38
- - reproducibility of simulation results, or
39
- - making sure refactorings in Modelica libraries do not alter the behavior.
40
-
41
- Other testing criteria could be memory consumption, CPU time and more.
42
-
43
- ## Why MoPyRegtest
44
- The scope of MoPyRegtest is to have a lightweight and simple way to perform regression tests and to be able to integrate
45
- this with automated testing and continuous integration (CI) toolchains, like e.g. GitHub Actions.
46
- Without immediately requiring commercial simulation tools or creating strong dependencies from other Modelica libraries.
47
-
48
- All that is needed to use MoPyRegtest is a Python 3 installation, an [OpenModelica](https://www.openmodelica.org/) installation,
49
- and a text editor.
50
-
51
- ## Current realization
52
- The current realization uses the [Python `unittest` module](https://docs.python.org/3/library/unittest.html) and calls the [OpenModelica compiler `omc`](https://openmodelica.org/) as an
53
- external executable for translation and simulation of Modelica models. Note that the implementation of MoPyRegtest is not
54
- specific to OpenModelica but can be replaced by any other Modelica simulation tool that comes with a suitable scripting API.
55
-
56
- The test execution and orchestration is done by the Python `unittest` module. In particular, Python `unittest` supports
57
- [test discovery](https://docs.python.org/3/library/unittest.html#test-discovery).
58
- Also, `unittest` is a standard module that comes with virtually all Python distributions.
59
-
60
- **MoPyRegtest is work in progress!**
61
-
62
- ## Usage and example
63
- With MoPyRegtest, users can define regression tests manually in Python for one Modelica model at a time,
64
- or automatically for many Modelica models simultaneously.
65
-
66
- ### Manual test case definition
67
- The user has to
68
- * provide Modelica models that can be translated, built and executed and produce a result `.csv` file
69
- * provide for every Modelica model a `.csv` file with a reference result against which an actual result is compared
70
- * create a Python file and test methods that instantiate a `mopyregtest.RegressionTest` object,
71
- which needs to know which Modelica model to test and where to find the reference result.
72
-
73
- Examples can be found in the `examples` folder. Also see the [examples/README.md](https://github.com/pstelzig/MoPyRegtest/tree/master/examples/README.md).
74
-
75
- ### Automatic test case generation
76
- MoPyRegtest can generate regression test definitions for elements of a Modelica library automatically.
77
- Either by creating [Generator class objects](https://github.com/pstelzig/MoPyRegtest/tree/master/mopyregtest/generator.py). Or using the
78
- [`mopyregtest` command line tool](https://github.com/pstelzig/MoPyRegtest/blob/master/mopyregtest/cli.py).
79
-
80
- The folder [examples/generate_tests/README.md](https://github.com/pstelzig/MoPyRegtest/tree/master/examples/generate_tests/README.md)
81
- has a detailed explanation on how to automatically generate tests.
82
-
83
- ## Prerequisites
84
- To use MoPyRegtest you need to have
85
- * a [Python 3](https://www.python.org/) distribution including the modules [`unittest`](https://docs.python.org/3/library/unittest.html), [`numpy`](https://numpy.org/) and [`pandas`](https://pandas.pydata.org/),
86
- * a working [OpenModelica](https://www.openmodelica.org/) installation (version 1.13.0 or later, works also for latest 1.22), and
87
- * the OpenModelica compiler executable `omc` must be accessible via the `PATH` variable.
88
-
89
- ## Installation using pip3
90
- It is most convenient to install MoPyRegtest using [Python's package manager `pip`](https://packaging.python.org/tutorials/installing-packages/).
91
- MoPyRegtest *does not need any special privileges* to run.
92
-
93
- ### Install from PyPI
94
- You can install MoPyRegtest from the [Python Package Index](https://pypi.org/project/MoPyRegtest/) by running
95
-
96
- ```bash
97
- pip3 install --user mopyregtest
98
- ```
99
-
100
- To install a specific version, e.g. `v0.3.1`, run `pip3 install --user mopyregtest==0.3.1`
101
-
102
- ### Install from source
103
- To install from source, first clone this repository to your local `<your-mopyregtest-dir>` (adapt to your needs) with
104
- the command `git clone https://github.com/pstelzig/MoPyRegtest.git <your-mopyregtest-dir>`
105
-
106
- Then run
107
-
108
- ```bash
109
- cd <your-mopyregtest-dir>
110
- pip3 install --user .
111
- ```
112
-
113
- to get the latest development head. To install a specific version from source, e.g. `v0.3.1`, run
114
-
115
- ```bash
116
- cd <your-mopyregtest-dir>
117
- git checkout v0.3.1
118
- pip3 install --user .
119
- ```
120
-
121
- ### Uninstall
122
- To uninstall MoPyRegtest, run
123
- ```bash
124
- pip3 uninstall mopyregtest
125
- ```
126
-
127
- ### Troubleshooting
128
-
129
- #### Problem: CLI `mopyregtest` cannot be found
130
- To check if MoPyRegtest's command line tool is working, run `mopyregtest --help` from a terminal.
131
-
132
- If an error message shows that the program `mopyregtest` cannot be found, then you have to check if your PATH variable
133
- knows where to find `mopyregtest` as installed by pip. To find out the location, run `pip uninstall mopyregtest` but do
134
- not confirm to proceed. The uninstallation will tell you which files pip would remove upon uninstalling MoPyRegtest,
135
- including the `mopyregtest` executable (or `mopyregtest.exe` under Windows) and its location.
136
-
137
- ```
138
- Found existing installation: MoPyRegtest 0.4.0rc1
139
- Uninstalling MoPyRegtest-0.4.0rc1:
140
- Would remove:
141
- /home/<your user name>/.local/bin/mopyregtest
142
- /home/<your user name>/.local/lib/python3.10/site-packages/MoPyRegtest-0.4.0rc1.dist-info/*
143
- /home/<your user name>/.local/lib/python3.10/site-packages/mopyregtest/*
144
- Proceed (Y/n)?
145
- ```
146
-
147
- Then, one could either call `mopyregtest` with its full path, or one could add its parent folder to the PATH
148
- variable (Be careful! First make sure that this does not cause any harm to your system).
149
-
150
- ## Future Work
151
- * Allow for parallel execution of regression tests
152
- * Improve readability of in particular failed test results
153
- * Provide logs that help users in the analysis of failed tests
154
- * Make definition of the tests even simpler, e.g. using a more human-readable BDD approach
155
-
156
- ## Open source software used
157
- MoPyRegtest is implemented in Python3 and uses the Python core modules (including `pathlib` and `unittest`) along with
158
- [`numpy`](https://numpy.org/) and [`pandas`](https://pandas.pydata.org/).
159
-
160
- # License
161
- MoPyRegtest is open source software. MoPyRegtest is provided "as is", without warranty of any kind.
162
- Usage is completely at your own risk. See the file `LICENSE`.
163
-
164
- # How to contribute
165
- If you want to help me extend MoPyRegtest, please drop me a message! Contributions are welcome!
166
-
167
- # Authors
168
- The MoPyRegtest is being developed by the following authors:
169
- * [Dr. Philipp Emanuel Stelzig](https://github.com/pstelzig)
170
-
@@ -1,154 +0,0 @@
1
- # MoPyRegtest: A Python enabled simple regression testing framework for Modelica models
2
-
3
- **General**
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/pstelzig/MoPyRegtest/tree/master/LICENSE)
5
- [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/pstelzig/MoPyRegtest/issues)
6
-
7
- **Project status**
8
- [![Unit tests](https://github.com/pstelzig/mopyregtest/actions/workflows/job-unit-tests.yml/badge.svg?branch=master)](https://github.com/pstelzig/MoPyRegtest/actions/workflows/job-unit-tests.yml)
9
- [![Examples](https://github.com/pstelzig/mopyregtest/actions/workflows/job-examples.yml/badge.svg?branch=master)](https://github.com/pstelzig/MoPyRegtest/actions/workflows/job-examples.yml)
10
- [![Example usage in other repo](https://github.com/pstelzig/mopyregtest/actions/workflows/job-example-for-other-repo.yml/badge.svg?branch=master)](https://github.com/pstelzig/MoPyRegtest/actions/workflows/job-example-for-other-repo.yml)
11
- [![Publish to PyPI](https://github.com/pstelzig/mopyregtest/actions/workflows/pythonpublish.yml/badge.svg)](https://pypi.org/project/MoPyRegtest/)
12
-
13
- Scope of this project is to
14
- * provide a simple regression testing framework for Modelica models
15
- * support continuous integration (CI) for Modelica library development, in particular
16
- * test for reproducibility of results from [Modelica](https://www.modelica.org/) models and to
17
- * have it wrapped in the well-known [Python `unittest` module](https://docs.python.org/3/library/unittest.html)
18
-
19
- ## Background:
20
- When developing Modelica models or libraries and releases have been made, there is definitely the need for testing. E.g.
21
- - validation of successful model translation,
22
- - reproducibility of simulation results, or
23
- - making sure refactorings in Modelica libraries do not alter the behavior.
24
-
25
- Other testing criteria could be memory consumption, CPU time and more.
26
-
27
- ## Why MoPyRegtest
28
- The scope of MoPyRegtest is to have a lightweight and simple way to perform regression tests and to be able to integrate
29
- this with automated testing and continuous integration (CI) toolchains, like e.g. GitHub Actions.
30
- Without immediately requiring commercial simulation tools or creating strong dependencies from other Modelica libraries.
31
-
32
- All that is needed to use MoPyRegtest is a Python 3 installation, an [OpenModelica](https://www.openmodelica.org/) installation,
33
- and a text editor.
34
-
35
- ## Current realization
36
- The current realization uses the [Python `unittest` module](https://docs.python.org/3/library/unittest.html) and calls the [OpenModelica compiler `omc`](https://openmodelica.org/) as an
37
- external executable for translation and simulation of Modelica models. Note that the implementation of MoPyRegtest is not
38
- specific to OpenModelica but can be replaced by any other Modelica simulation tool that comes with a suitable scripting API.
39
-
40
- The test execution and orchestration is done by the Python `unittest` module. In particular, Python `unittest` supports
41
- [test discovery](https://docs.python.org/3/library/unittest.html#test-discovery).
42
- Also, `unittest` is a standard module that comes with virtually all Python distributions.
43
-
44
- **MoPyRegtest is work in progress!**
45
-
46
- ## Usage and example
47
- With MoPyRegtest, users can define regression tests manually in Python for one Modelica model at a time,
48
- or automatically for many Modelica models simultaneously.
49
-
50
- ### Manual test case definition
51
- The user has to
52
- * provide Modelica models that can be translated, built and executed and produce a result `.csv` file
53
- * provide for every Modelica model a `.csv` file with a reference result against which an actual result is compared
54
- * create a Python file and test methods that instantiate a `mopyregtest.RegressionTest` object,
55
- which needs to know which Modelica model to test and where to find the reference result.
56
-
57
- Examples can be found in the `examples` folder. Also see the [examples/README.md](https://github.com/pstelzig/MoPyRegtest/tree/master/examples/README.md).
58
-
59
- ### Automatic test case generation
60
- MoPyRegtest can generate regression test definitions for elements of a Modelica library automatically.
61
- Either by creating [Generator class objects](https://github.com/pstelzig/MoPyRegtest/tree/master/mopyregtest/generator.py). Or using the
62
- [`mopyregtest` command line tool](https://github.com/pstelzig/MoPyRegtest/blob/master/mopyregtest/cli.py).
63
-
64
- The folder [examples/generate_tests/README.md](https://github.com/pstelzig/MoPyRegtest/tree/master/examples/generate_tests/README.md)
65
- has a detailed explanation on how to automatically generate tests.
66
-
67
- ## Prerequisites
68
- To use MoPyRegtest you need to have
69
- * a [Python 3](https://www.python.org/) distribution including the modules [`unittest`](https://docs.python.org/3/library/unittest.html), [`numpy`](https://numpy.org/) and [`pandas`](https://pandas.pydata.org/),
70
- * a working [OpenModelica](https://www.openmodelica.org/) installation (version 1.13.0 or later, works also for latest 1.22), and
71
- * the OpenModelica compiler executable `omc` must be accessible via the `PATH` variable.
72
-
73
- ## Installation using pip3
74
- It is most convenient to install MoPyRegtest using [Python's package manager `pip`](https://packaging.python.org/tutorials/installing-packages/).
75
- MoPyRegtest *does not need any special privileges* to run.
76
-
77
- ### Install from PyPI
78
- You can install MoPyRegtest from the [Python Package Index](https://pypi.org/project/MoPyRegtest/) by running
79
-
80
- ```bash
81
- pip3 install --user mopyregtest
82
- ```
83
-
84
- To install a specific version, e.g. `v0.3.1`, run `pip3 install --user mopyregtest==0.3.1`
85
-
86
- ### Install from source
87
- To install from source, first clone this repository to your local `<your-mopyregtest-dir>` (adapt to your needs) with
88
- the command `git clone https://github.com/pstelzig/MoPyRegtest.git <your-mopyregtest-dir>`
89
-
90
- Then run
91
-
92
- ```bash
93
- cd <your-mopyregtest-dir>
94
- pip3 install --user .
95
- ```
96
-
97
- to get the latest development head. To install a specific version from source, e.g. `v0.3.1`, run
98
-
99
- ```bash
100
- cd <your-mopyregtest-dir>
101
- git checkout v0.3.1
102
- pip3 install --user .
103
- ```
104
-
105
- ### Uninstall
106
- To uninstall MoPyRegtest, run
107
- ```bash
108
- pip3 uninstall mopyregtest
109
- ```
110
-
111
- ### Troubleshooting
112
-
113
- #### Problem: CLI `mopyregtest` cannot be found
114
- To check if MoPyRegtest's command line tool is working, run `mopyregtest --help` from a terminal.
115
-
116
- If an error message shows that the program `mopyregtest` cannot be found, then you have to check if your PATH variable
117
- knows where to find `mopyregtest` as installed by pip. To find out the location, run `pip uninstall mopyregtest` but do
118
- not confirm to proceed. The uninstallation will tell you which files pip would remove upon uninstalling MoPyRegtest,
119
- including the `mopyregtest` executable (or `mopyregtest.exe` under Windows) and its location.
120
-
121
- ```
122
- Found existing installation: MoPyRegtest 0.4.0rc1
123
- Uninstalling MoPyRegtest-0.4.0rc1:
124
- Would remove:
125
- /home/<your user name>/.local/bin/mopyregtest
126
- /home/<your user name>/.local/lib/python3.10/site-packages/MoPyRegtest-0.4.0rc1.dist-info/*
127
- /home/<your user name>/.local/lib/python3.10/site-packages/mopyregtest/*
128
- Proceed (Y/n)?
129
- ```
130
-
131
- Then, one could either call `mopyregtest` with its full path, or one could add its parent folder to the PATH
132
- variable (Be careful! First make sure that this does not cause any harm to your system).
133
-
134
- ## Future Work
135
- * Allow for parallel execution of regression tests
136
- * Improve readability of in particular failed test results
137
- * Provide logs that help users in the analysis of failed tests
138
- * Make definition of the tests even simpler, e.g. using a more human-readable BDD approach
139
-
140
- ## Open source software used
141
- MoPyRegtest is implemented in Python3 and uses the Python core modules (including `pathlib` and `unittest`) along with
142
- [`numpy`](https://numpy.org/) and [`pandas`](https://pandas.pydata.org/).
143
-
144
- # License
145
- MoPyRegtest is open source software. MoPyRegtest is provided "as is", without warranty of any kind.
146
- Usage is completely at your own risk. See the file `LICENSE`.
147
-
148
- # How to contribute
149
- If you want to help me extend MoPyRegtest, please drop me a message! Contributions are welcome!
150
-
151
- # Authors
152
- The MoPyRegtest is being developed by the following authors:
153
- * [Dr. Philipp Emanuel Stelzig](https://github.com/pstelzig)
154
-
File without changes
File without changes