Skip to content

Commit ac4de96

Browse files
committed
fixes
1 parent 948f522 commit ac4de96

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

scenario_execution/test/test_scenario_compositions.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,16 @@ def setUp(self) -> None:
4040
self.scenario_execution = ScenarioExecution(debug=True, log_model=True, live_tree=True, scenario_file='test.osc', output_dir="")
4141
self.tree = py_trees.composites.Sequence(name="", memory=True)
4242

43-
def execute(self, scenario_content):
43+
def execute(self, scenario_content, expected_result=True):
4444
self.logger.reset()
45-
parsed_tree = self.parser.parse_input_stream(InputStream(scenario_content))
46-
model = self.parser.create_internal_model(parsed_tree, self.tree, "test.osc", False)
47-
self.tree = create_py_tree(model, self.tree, self.logger, False)
45+
try:
46+
parsed_tree = self.parser.parse_input_stream(InputStream(scenario_content))
47+
model = self.parser.create_internal_model(parsed_tree, self.tree, "test.osc", False)
48+
self.tree = create_py_tree(model, self.tree, self.logger, False)
49+
except Exception as e:
50+
if expected_result:
51+
raise e
52+
return
4853
self.scenario_execution.tree = self.tree
4954
self.scenario_execution.run()
5055

@@ -122,8 +127,7 @@ def test_serial_no_memory(self):
122127
log("B")
123128
emit end
124129
"""
125-
self.execute(scenario_content)
126-
self.assertFalse(self.scenario_execution.process_results())
130+
self.execute(scenario_content, False)
127131

128132
def test_selector(self):
129133
scenario_content = """
@@ -136,8 +140,7 @@ def test_selector(self):
136140
log("A")
137141
log("B")
138142
"""
139-
self.execute(scenario_content)
140-
self.assertFalse(self.scenario_execution.process_results())
143+
self.execute(scenario_content, False)
141144

142145
def test_selector_no_memory(self):
143146
scenario_content = """
@@ -150,8 +153,7 @@ def test_selector_no_memory(self):
150153
run_process("false")
151154
log("B")
152155
"""
153-
self.execute(scenario_content)
154-
self.assertFalse(self.scenario_execution.process_results())
156+
self.execute(scenario_content, False)
155157

156158
def test_selector_no_memory_second_false(self):
157159
scenario_content = """
@@ -164,5 +166,4 @@ def test_selector_no_memory_second_false(self):
164166
log("A")
165167
run_process("false")
166168
"""
167-
self.execute(scenario_content)
168-
self.assertFalse(self.scenario_execution.process_results())
169+
self.execute(scenario_content, False)

scenario_execution/test/test_scenario_compositions_scx.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from scenario_execution.model.model_to_py_tree import create_py_tree
2222
from scenario_execution.utils.logging import Logger
2323
from antlr4.InputStream import InputStream
24-
from datetime import datetime
2524
from .common import DebugLogger
2625

2726

@@ -39,7 +38,7 @@ def setUp(self) -> None:
3938

4039
def execute(self, scenario_content):
4140
self.logger.reset()
42-
parsed_tree = self.parser.parse_input_stream(InputStream(scenario_content))
41+
parsed_tree = self.parser.parse_input_stream(InputStream(scenario_content), enable_extensions=True)
4342
model = self.parser.create_internal_model(parsed_tree, self.tree, "test.scx", False)
4443
self.tree = create_py_tree(model, self.tree, self.logger, False)
4544
self.scenario_execution.tree = self.tree

0 commit comments

Comments
 (0)