1- # Copyright (C) 2024 Intel Corporation
1+ # Copyright (C) 2025 Frederik Pasch
22#
33# Licensed under the Apache License, Version 2.0 (the "License");
44# you may not use this file except in compliance with the License.
1414#
1515# SPDX-License-Identifier: Apache-2.0
1616
17- """
18- Test parallel parsing
19- """
2017import unittest
2118import py_trees
2219from scenario_execution .scenario_execution_base import ScenarioExecution
@@ -40,18 +37,17 @@ def setUp(self) -> None:
4037 self .scenario_execution = ScenarioExecution (debug = True , log_model = True , live_tree = True , scenario_file = 'test.osc' , output_dir = "" )
4138 self .tree = py_trees .composites .Sequence (name = "" , memory = True )
4239
43- def execute (self , scenario_content , expected_result = True ):
40+ def execute (self , scenario_content ):
4441 self .logger .reset ()
4542 try :
4643 parsed_tree = self .parser .parse_input_stream (InputStream (scenario_content ))
4744 model = self .parser .create_internal_model (parsed_tree , self .tree , "test.osc" , False )
4845 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
46+ except Exception as e : # pylint: disable=broad-except
47+ return False
5348 self .scenario_execution .tree = self .tree
5449 self .scenario_execution .run ()
50+ return True
5551
5652 def test_parallel (self ):
5753 scenario_content = """
@@ -69,7 +65,7 @@ def test_parallel(self):
6965 wait elapsed(1s)
7066 emit fail
7167"""
72- self .execute (scenario_content )
68+ self .assertTrue ( self . execute (scenario_content ) )
7369 self .assertTrue (self .scenario_execution .process_results ())
7470
7571 def test_oneof (self ):
@@ -109,7 +105,7 @@ def test_serial(self):
109105 log("B")
110106 emit end
111107"""
112- self .execute (scenario_content )
108+ self .assertTrue ( self . execute (scenario_content ) )
113109 self .assertTrue (self .scenario_execution .process_results ())
114110 self .assertEqual (len (self .logger .logs_info ), 2 )
115111 self .assertEqual (self .logger .logs_info [0 ], "A" )
@@ -127,7 +123,7 @@ def test_serial_no_memory(self):
127123 log("B")
128124 emit end
129125"""
130- self .execute (scenario_content , False )
126+ self .assertFalse ( self . execute (scenario_content ) )
131127
132128 def test_selector (self ):
133129 scenario_content = """
@@ -140,7 +136,7 @@ def test_selector(self):
140136 log("A")
141137 log("B")
142138"""
143- self .execute (scenario_content , False )
139+ self .assertFalse ( self . execute (scenario_content ) )
144140
145141 def test_selector_no_memory (self ):
146142 scenario_content = """
@@ -153,7 +149,7 @@ def test_selector_no_memory(self):
153149 run_process("false")
154150 log("B")
155151"""
156- self .execute (scenario_content , False )
152+ self .assertFalse ( self . execute (scenario_content ) )
157153
158154 def test_selector_no_memory_second_false (self ):
159155 scenario_content = """
@@ -166,4 +162,4 @@ def test_selector_no_memory_second_false(self):
166162 log("A")
167163 run_process("false")
168164"""
169- self .execute (scenario_content , False )
165+ self .assertFalse ( self . execute (scenario_content ) )
0 commit comments