88
99# stdlib
1010from math import isclose
11+ from typing import List , Tuple , Type
1112
1213# 3rd party
1314import pytest
2829 Size_mm ,
2930 Size_pica ,
3031 Size_um ,
32+ Unit ,
3133 cm ,
3234 convert_from ,
3335 inch ,
6567 ),
6668 ],
6769 )
68- def test_repr (obj , expects ):
70+ def test_repr (obj : Unit , expects : str ):
6971 assert repr (obj ) == expects
7072
7173
@@ -78,12 +80,12 @@ def test_repr(obj, expects):
7880 (Size_pica (12 , 34 ), "Size_pica(width=12, height=34)" ),
7981 ],
8082 )
81- def test_str (obj , expects ):
83+ def test_str (obj : Unit , expects : str ):
8284 assert str (obj ) == expects
8385
8486
8587@pytest .mark .parametrize ("size" , [A6 , A5 , A4 , A3 , A2 , A1 , A0 ])
86- def test_orientation (size ):
88+ def test_orientation (size : BaseSize ):
8789 assert size .is_portrait ()
8890 assert size .portrait ().is_portrait ()
8991 assert size .landscape ().portrait ().is_portrait ()
@@ -106,7 +108,7 @@ def test_is_square():
106108
107109
108110@pytest .mark .parametrize ("unit" , [pt , inch , cm , mm , um , pc ])
109- def test_convert_size (unit ):
111+ def test_convert_size (unit : Unit ):
110112 size = PageSize (12 , 34 , unit )
111113 unit_str = unit .name
112114 if unit_str == "µm" :
@@ -176,7 +178,7 @@ def test_convert_size(unit):
176178 pytest .param (2 , 5 , 10 , id = "not isinstance(from_, Unit)" ),
177179 ],
178180 )
179- def test_convert_from (value , unit , expects ):
181+ def test_convert_from (value : List [ int ] , unit , expects : Tuple [ float , ...] ):
180182 assert convert_from (value , unit ) == expects
181183
182184
@@ -187,7 +189,7 @@ def test_convert_from(value, unit, expects):
187189 ((12 , 34 ), Size_mm (12 , 34 ), Size_mm ),
188190 ],
189191 )
190- def test_from_size (size , expected , class_ ):
192+ def test_from_size (size : Tuple [ int , int ], expected : Unit , class_ : Type [ BaseSize ] ):
191193 print (class_ .from_size (size ))
192194 assert class_ .from_size (size ) == expected
193195
@@ -210,7 +212,7 @@ def test_from_size(size, expected, class_):
210212 ("10μm" , [("10" , "μm" )]),
211213 ],
212214 )
213- def test_measurement_re (string , expects ):
215+ def test_measurement_re (string : str , expects : Unit ):
214216 assert _measurement_re .findall (string ) == expects
215217
216218
@@ -261,5 +263,5 @@ def test_parse_measurement_errors():
261263 ("5in" , 5 * inch ),
262264 ],
263265 )
264- def test_parse_measurement (string , expects ):
266+ def test_parse_measurement (string : str , expects : Unit ):
265267 assert parse_measurement (string ) == expects
0 commit comments