2
2
import pytest
3
3
import logging
4
4
5
- from matplotlib import afm
5
+ from matplotlib import _afm
6
6
from matplotlib import font_manager as fm
7
7
8
8
@@ -39,13 +39,13 @@ def test_nonascii_str():
39
39
inp_str = "привет"
40
40
byte_str = inp_str .encode ("utf8" )
41
41
42
- ret = afm ._to_str (byte_str )
42
+ ret = _afm ._to_str (byte_str )
43
43
assert ret == inp_str
44
44
45
45
46
46
def test_parse_header ():
47
47
fh = BytesIO (AFM_TEST_DATA )
48
- header = afm ._parse_header (fh )
48
+ header = _afm ._parse_header (fh )
49
49
assert header == {
50
50
b'StartFontMetrics' : 2.0 ,
51
51
b'FontName' : 'MyFont-Bold' ,
@@ -66,8 +66,8 @@ def test_parse_header():
66
66
67
67
def test_parse_char_metrics ():
68
68
fh = BytesIO (AFM_TEST_DATA )
69
- afm ._parse_header (fh ) # position
70
- metrics = afm ._parse_char_metrics (fh )
69
+ _afm ._parse_header (fh ) # position
70
+ metrics = _afm ._parse_char_metrics (fh )
71
71
assert metrics == (
72
72
{0 : (250.0 , 'space' , [0 , 0 , 0 , 0 ]),
73
73
42 : (1141.0 , 'foo' , [40 , 60 , 800 , 360 ]),
@@ -81,13 +81,13 @@ def test_parse_char_metrics():
81
81
82
82
def test_get_familyname_guessed ():
83
83
fh = BytesIO (AFM_TEST_DATA )
84
- font = afm .AFM (fh )
84
+ font = _afm .AFM (fh )
85
85
del font ._header [b'FamilyName' ] # remove FamilyName, so we have to guess
86
86
assert font .get_familyname () == 'My Font'
87
87
88
88
89
89
def test_font_manager_weight_normalization ():
90
- font = afm .AFM (BytesIO (
90
+ font = _afm .AFM (BytesIO (
91
91
AFM_TEST_DATA .replace (b"Weight Bold\n " , b"Weight Custom\n " )))
92
92
assert fm .afmFontProperty ("" , font ).weight == "normal"
93
93
@@ -107,7 +107,7 @@ def test_font_manager_weight_normalization():
107
107
def test_bad_afm (afm_data ):
108
108
fh = BytesIO (afm_data )
109
109
with pytest .raises (RuntimeError ):
110
- afm ._parse_header (fh )
110
+ _afm ._parse_header (fh )
111
111
112
112
113
113
@pytest .mark .parametrize (
@@ -132,6 +132,6 @@ def test_bad_afm(afm_data):
132
132
def test_malformed_header (afm_data , caplog ):
133
133
fh = BytesIO (afm_data )
134
134
with caplog .at_level (logging .ERROR ):
135
- afm ._parse_header (fh )
135
+ _afm ._parse_header (fh )
136
136
137
137
assert len (caplog .records ) == 1
0 commit comments