@@ -312,16 +312,6 @@ def test_from_image_file_raises_isadirectoryerror_with_dir():
312312 layout .DocumentLayout .from_image_file (tempdir )
313313
314314
315- @pytest .mark .parametrize ("idx" , range (2 ))
316- def test_get_elements_from_layout (mock_initial_layout , idx ):
317- page = MockPageLayout ()
318- block = mock_initial_layout [idx ]
319- block .bbox .pad (3 )
320- fixed_layout = [block ]
321- elements = page .get_elements_from_layout (fixed_layout )
322- assert elements [0 ].text == block .text
323-
324-
325315def test_page_numbers_in_page_objects ():
326316 with patch (
327317 "unstructured_inference.inference.layout.PageLayout.get_elements_with_detection_model" ,
@@ -331,40 +321,6 @@ def test_page_numbers_in_page_objects():
331321 assert [page .number for page in doc .pages ] == list (range (1 , len (doc .pages ) + 1 ))
332322
333323
334- @pytest .mark .parametrize (
335- ("fixed_layouts" , "called_method" , "not_called_method" ),
336- [
337- (
338- [MockLayout ()],
339- "get_elements_from_layout" ,
340- "get_elements_with_detection_model" ,
341- ),
342- (None , "get_elements_with_detection_model" , "get_elements_from_layout" ),
343- ],
344- )
345- def test_from_file_fixed_layout (fixed_layouts , called_method , not_called_method ):
346- with patch .object (
347- layout .PageLayout ,
348- "get_elements_with_detection_model" ,
349- return_value = [],
350- ), patch .object (
351- layout .PageLayout ,
352- "get_elements_from_layout" ,
353- return_value = [],
354- ):
355- layout .DocumentLayout .from_file ("sample-docs/loremipsum.pdf" , fixed_layouts = fixed_layouts )
356- getattr (layout .PageLayout , called_method ).assert_called ()
357- getattr (layout .PageLayout , not_called_method ).assert_not_called ()
358-
359-
360- @pytest .mark .parametrize (
361- ("text" , "expected" ),
362- [("c\t o\x0c n\f trol\n character\r s\b " , "control characters" ), ("\" '\\ " , "\" '\\ " )],
363- )
364- def test_remove_control_characters (text , expected ):
365- assert elements .remove_control_characters (text ) == expected
366-
367-
368324no_text_region = EmbeddedTextRegion .from_coords (0 , 0 , 100 , 100 )
369325text_region = EmbeddedTextRegion .from_coords (0 , 0 , 100 , 100 , text = "test" )
370326overlapping_rect = ImageTextRegion .from_coords (50 , 50 , 150 , 150 )
@@ -417,12 +373,6 @@ def check_annotated_image():
417373 check_annotated_image ()
418374
419375
420- @pytest .mark .parametrize (("text" , "expected" ), [("asdf" , "asdf" ), (None , "" )])
421- def test_embedded_text_region (text , expected ):
422- etr = elements .EmbeddedTextRegion .from_coords (0 , 0 , 24 , 24 , text = text )
423- assert etr .extract_text (objects = None ) == expected
424-
425-
426376class MockDetectionModel (layout .UnstructuredObjectDetectionModel ):
427377 def initialize (self , * args , ** kwargs ):
428378 pass
0 commit comments