@@ -181,7 +181,7 @@ def test_xml_parser_remapping(self) -> None:
181181
182182 def test_grandparent_xml (self ) -> None :
183183 """Test XML parser with grandparent-child relationships and correct value propagation."""
184- xml_path = os .path .join (os .path .dirname (__file__ ), "grandparent_test.xml" )
184+ xml_path = os .path .join (os .path .dirname (__file__ ), "xml" , " grandparent_test.xml" )
185185 root_node = parse_behaviour_tree_xml (xml_path , logger = StdoutLogger ())
186186 btree = py_trees .trees .BehaviourTree (root_node )
187187 btree .tick ()
@@ -888,6 +888,33 @@ def test_import_with_search_paths(self) -> None:
888888 assert isinstance (c , Consumer )
889889 self .assertEqual (c .consumed_value , "Producer[/L:L.MySeq.P]" )
890890
891+ def test_include_subtree_file_with_search_paths (self ) -> None :
892+ """A subtree <Include>d from a sibling directory resolves via 'search_paths'.
893+
894+ Uses the on-disk fixtures in tests/xml/: the main tree includes
895+ 'subtree_library.xml', which lives in tests/xml/subtrees/ and is therefore
896+ only found when that directory is passed via 'search_paths'.
897+ """
898+ xml_dir = os .path .join (os .path .dirname (__file__ ), "xml" )
899+ main_path = os .path .join (xml_dir , "main_tree_with_include.xml" )
900+ root = parse_behaviour_tree_xml (
901+ main_path ,
902+ logger = StdoutLogger (),
903+ search_paths = [os .path .join (xml_dir , "subtrees" )],
904+ )
905+ tree = py_trees .trees .BehaviourTree (root )
906+ tree .tick ()
907+ consumer = find_node_by_name (root , "FinalConsumer" , strip_prefix = True )
908+ assert isinstance (consumer , Consumer )
909+ self .assertEqual (consumer .consumed_value , "Producer[/Library:Library.LibSeq.LibProducer]" )
910+
911+ def test_include_subtree_file_without_search_paths_fails (self ) -> None :
912+ """Without 'search_paths', the include in tests/xml/ cannot be resolved."""
913+ xml_dir = os .path .join (os .path .dirname (__file__ ), "xml" )
914+ main_path = os .path .join (xml_dir , "main_tree_with_include.xml" )
915+ with self .assertRaises (FileNotFoundError ):
916+ parse_behaviour_tree_xml (main_path , logger = StdoutLogger ())
917+
891918 def test_imported_bt_missing_id (self ) -> None :
892919 """Imported file containing a <BehaviorTree> without an ID raises ValueError."""
893920 lib_path = self ._write_temp_xml ("""<root><BehaviorTree><Sequence/></BehaviorTree></root>""" )
0 commit comments