17
17
from docx .image .png import Png
18
18
from docx .image .tiff import Tiff
19
19
from docx .opc .constants import CONTENT_TYPE as CT
20
+ from docx .shared import Length
20
21
21
22
from ..unitutil .file import test_file
22
23
from ..unitutil .mock import (
@@ -71,7 +72,7 @@ def it_knows_the_image_content_type(self, content_type_fixture):
71
72
image = Image (None , None , image_header_ )
72
73
assert image .content_type == content_type
73
74
74
- def it_knows_the_image_dimensions (self , dimensions_fixture ):
75
+ def it_knows_the_image_px_dimensions (self , dimensions_fixture ):
75
76
image_header_ , px_width , px_height = dimensions_fixture
76
77
image = Image (None , None , image_header_ )
77
78
assert image .px_width == px_width
@@ -83,6 +84,12 @@ def it_knows_the_horz_and_vert_dpi_of_the_image(self, dpi_fixture):
83
84
assert image .horz_dpi == horz_dpi
84
85
assert image .vert_dpi == vert_dpi
85
86
87
+ def it_knows_the_image_native_size (self , size_fixture ):
88
+ image , width , height = size_fixture
89
+ assert (image .width , image .height ) == (width , height )
90
+ assert isinstance (image .width , Length )
91
+ assert isinstance (image .height , Length )
92
+
86
93
def it_knows_the_image_filename (self ):
87
94
filename = 'foobar.png'
88
95
image = Image (None , filename , None )
@@ -182,6 +189,13 @@ def known_image_fixture(self, request):
182
189
image_filename , characteristics = cases [request .param ]
183
190
return image_filename , characteristics
184
191
192
+ @pytest .fixture
193
+ def size_fixture (self , image_header_ ):
194
+ image_header_ .px_width , image_header_ .px_height = 150 , 75
195
+ image_header_ .horz_dpi , image_header_ .vert_dpi = 72 , 200
196
+ image = Image (None , None , image_header_ )
197
+ return image , 1905000 , 342900
198
+
185
199
# fixture components ---------------------------------------------
186
200
187
201
@pytest .fixture
0 commit comments