@@ -872,3 +872,26 @@ def test_invalid_syntax_raises_syntax_error(self):
872872 doc = Document (content = "class Broken(\n pass\n " )
873873 with pytest .raises (SyntaxError ):
874874 splitter .run (documents = [doc ])
875+
876+
877+ class TestSecondarySplitQualifiedName :
878+ def test_first_piece_has_no_prefix (self , oversized_function_source ):
879+ splitter = PythonCodeSplitter (min_effective_lines = 2 , max_effective_lines = 5 , oversized_factor = 3 )
880+ result = splitter .run (documents = [Document (content = oversized_function_source )])
881+ secondary = sorted (
882+ (c for c in result ["documents" ] if c .meta .get ("secondary_split" )),
883+ key = lambda c : c .meta ["secondary_split_index" ],
884+ )
885+ assert secondary
886+ assert not (secondary [0 ].content or "" ).startswith ("# giant" )
887+
888+ def test_non_first_pieces_are_prefixed_with_qualified_name (self , oversized_function_source ):
889+ splitter = PythonCodeSplitter (min_effective_lines = 2 , max_effective_lines = 5 , oversized_factor = 3 )
890+ result = splitter .run (documents = [Document (content = oversized_function_source )])
891+ secondary = sorted (
892+ (c for c in result ["documents" ] if c .meta .get ("secondary_split" )),
893+ key = lambda c : c .meta ["secondary_split_index" ],
894+ )
895+ assert len (secondary ) >= 2
896+ for piece in secondary [1 :]:
897+ assert (piece .content or "" ).startswith ("# giant" )
0 commit comments