MCPcopy Index your code
hub / github.com/python-openxml/python-docx / it_can_add_a_picture

Method it_can_add_a_picture

tests/text/test_run.py:299–319  ·  view source on GitHub ↗
(
        self,
        part_prop_: Mock,
        document_part_: Mock,
        InlineShape_: Mock,
        picture_: Mock,
        paragraph_: Mock,
    )

Source from the content-addressed store, hash-verified

297 assert run._r.xml == xml(expected_cxml)
298
299 def it_can_add_a_picture(
300 self,
301 part_prop_: Mock,
302 document_part_: Mock,
303 InlineShape_: Mock,
304 picture_: Mock,
305 paragraph_: Mock,
306 ):
307 part_prop_.return_value = document_part_
308 run = Run(cast(CT_R, element("w:r/wp:x")), paragraph_)
309 image = "foobar.png"
310 width, height, inline = 1111, 2222, element("wp:inline{id=42}")
311 document_part_.new_pic_inline.return_value = inline
312 InlineShape_.return_value = picture_
313
314 picture = run.add_picture(image, width, height)
315
316 document_part_.new_pic_inline.assert_called_once_with(image, width, height)
317 assert run._r.xml == xml("w:r/(wp:x,w:drawing/wp:inline{id=42})")
318 InlineShape_.assert_called_once_with(inline)
319 assert picture is picture_
320
321 @pytest.mark.parametrize(
322 ("initial_r_cxml", "expected_cxml"),

Callers

nothing calls this directly

Calls 4

add_pictureMethod · 0.95
RunClass · 0.90
elementFunction · 0.85
xmlFunction · 0.85

Tested by

no test coverage detected