Skip to content

Commit

Permalink
Fixed a few quality errors and tests (follow-errors from changes done…
Browse files Browse the repository at this point in the history
… on assertion
  • Loading branch information
eisDNV committed Dec 14, 2024
1 parent d8cfd40 commit b7a4d70
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/sim_explorer/simulator_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from libcosimpy.CosimEnums import CosimVariableCausality, CosimVariableType, CosimVariableVariability # type: ignore
from libcosimpy.CosimExecution import CosimExecution # type: ignore
from libcosimpy.CosimLogging import CosimLogLevel, log_output_level # type: ignore
from libcosimpy.CosimLogging import CosimLogLevel, log_output_level # type: ignore
from libcosimpy.CosimManipulator import CosimManipulator # type: ignore
from libcosimpy.CosimObserver import CosimObserver # type: ignore

Expand Down
9 changes: 5 additions & 4 deletions tests/test_assertion.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ def test_do_assert(show):
cases = Cases(spec=Path(__file__).parent / "data" / "BouncingBall3D" / "BouncingBall3D.cases")
case = cases.case_by_name("restitutionAndGravity")
case.run()
#res = Results(file=Path(__file__).parent / "data" / "BouncingBall3D" / "restitutionAndGravity.js5")
# res = Results(file=Path(__file__).parent / "data" / "BouncingBall3D" / "restitutionAndGravity.js5")
res = case.res
assert isinstance(res, Results)
# cases = res.case.cases
assert res.case.name == "restitutionAndGravity"
assert cases.file.name == "BouncingBall3D.cases"
Expand Down Expand Up @@ -242,8 +243,8 @@ def test_do_assert(show):


if __name__ == "__main__":
# retcode = pytest.main(["-rA", "-v", __file__, "--show", "False"])
# assert retcode == 0, f"Non-zero return code {retcode}"
retcode = pytest.main(["-rA", "-v", __file__, "--show", "False"])
assert retcode == 0, f"Non-zero return code {retcode}"
import os

os.chdir(Path(__file__).parent.absolute() / "test_working_directory")
Expand All @@ -253,4 +254,4 @@ def test_do_assert(show):
# test_assertion()
# test_assertion_spec()
# test_vector()
test_do_assert(show=True)
# test_do_assert(show=True)
8 changes: 4 additions & 4 deletions tests/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _make_cases():

# @pytest.mark.skip(reason="Deactivated")
def test_case_at_time(simpletable):
# print("DISECT", simpletable.case_by_name("base")._disect_at_time("x@step", ""))
# print("DISECT", simpletable.case_by_name("base")._disect_at_time_spec("x@step", ""))
do_case_at_time("[email protected]", "base", "res", ("v", "get", 1.0), simpletable)
return
do_case_at_time("x@step", "base", "res", ("x", "step", -1), simpletable)
Expand All @@ -91,7 +91,7 @@ def test_case_at_time(simpletable):
"@1.0",
"base",
"result",
"'@1.0' is not allowed as basis for _disect_at_time",
"'@1.0' is not allowed as basis for _disect_at_time_spec",
simpletable,
)
do_case_at_time("i", "base", "res", ("i", "get", 1), simpletable) # "report the value at end of sim!"
Expand All @@ -105,10 +105,10 @@ def do_case_at_time(txt, casename, value, expected, simpletable):
assert case is not None, f"Case {casename} was not found"
if isinstance(expected, str): # error case
with pytest.raises(AssertionError) as err:
case._disect_at_time(txt, value)
case._disect_at_time_spec(txt, value)
assert str(err.value).startswith(expected)
else:
assert case._disect_at_time(txt, value) == expected, f"Found {case._disect_at_time(txt, value)}"
assert case._disect_at_time_spec(txt, value) == expected, f"Found {case._disect_at_time(txt, value)}"


# @pytest.mark.skip(reason="Deactivated")
Expand Down

0 comments on commit b7a4d70

Please sign in to comment.