File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1
1
from io import BytesIO
2
2
import pytest
3
+ import logging
3
4
4
5
from matplotlib import afm
5
6
from matplotlib import font_manager as fm
@@ -107,3 +108,30 @@ def test_bad_afm(afm_data):
107
108
fh = BytesIO (afm_data )
108
109
with pytest .raises (RuntimeError ):
109
110
header = afm ._parse_header (fh )
111
+
112
+
113
+ @pytest .mark .parametrize (
114
+ "afm_data" ,
115
+ [
116
+ b"""StartFontMetrics 2.0
117
+ Comment Comments are ignored.
118
+ Comment Creation Date:Mon Nov 13 12:34:11 GMT 2017
119
+ Aardvark bob
120
+ FontName MyFont-Bold
121
+ EncodingScheme FontSpecific
122
+ StartCharMetrics 3""" ,
123
+ b"""StartFontMetrics 2.0
124
+ Comment Comments are ignored.
125
+ Comment Creation Date:Mon Nov 13 12:34:11 GMT 2017
126
+ ItalicAngle zero degrees
127
+ FontName MyFont-Bold
128
+ EncodingScheme FontSpecific
129
+ StartCharMetrics 3""" ,
130
+ ],
131
+ )
132
+ def test_malformed_header (afm_data , caplog ):
133
+ fh = BytesIO (afm_data )
134
+ with caplog .at_level (logging .ERROR ):
135
+ header = afm ._parse_header (fh )
136
+
137
+ assert len (caplog .records ) == 1
You can’t perform that action at this time.
0 commit comments