File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from io import BytesIO
22import pytest
3+ import logging
34
45from matplotlib import afm
56from matplotlib import font_manager as fm
@@ -107,3 +108,30 @@ def test_bad_afm(afm_data):
107108 fh = BytesIO (afm_data )
108109 with pytest .raises (RuntimeError ):
109110 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