forked from OpenModelica/OMPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_ModelicaSystemCmd.py
More file actions
51 lines (41 loc) · 1.14 KB
/
test_ModelicaSystemCmd.py
File metadata and controls
51 lines (41 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import OMPython
import pytest
@pytest.fixture
def model_firstorder(tmp_path):
mod = tmp_path / "M.mo"
mod.write_text("""model M
Real x(start = 1, fixed = true);
parameter Real a = -1;
equation
der(x) = x*a;
end M;
""")
return mod
@pytest.fixture
def mscmd_firstorder(model_firstorder):
mod = OMPython.ModelicaSystem(fileName=model_firstorder.as_posix(), modelName="M")
mscmd = OMPython.ModelicaSystemCmd(runpath=mod.getWorkDirectory(), modelname=mod._model_name)
return mscmd
def test_simflags(mscmd_firstorder):
mscmd = mscmd_firstorder
mscmd.args_set({
"noEventEmit": None,
"override": {'b': 2}
})
with pytest.deprecated_call():
mscmd.args_set(args=mscmd.parse_simflags(simflags="-noEventEmit -noRestart -override=a=1,x=3"))
assert mscmd.get_cmd() == [
mscmd.get_exe().as_posix(),
'-noEventEmit',
'-noRestart',
'-override=a=1,b=2,x=3',
]
mscmd.args_set({
"override": {'b': None},
})
assert mscmd.get_cmd() == [
mscmd.get_exe().as_posix(),
'-noEventEmit',
'-noRestart',
'-override=a=1,x=3',
]