8
8
9
9
10
10
def make_html (style : str , body : str ) -> str :
11
- return "<html><head><style>{style}</style></head><body>{body}</body></html>" .format (
12
- style = style , body = body
13
- )
11
+ return "<html><head><style>{style}</style></head><body>{body}</body></html>" .format (style = style , body = body )
14
12
15
13
16
14
SAMPLE_STYLE = """h1, h2 { color:red; }
@@ -60,9 +58,7 @@ def test_inline_many_wrong_type():
60
58
61
59
62
60
def test_missing_stylesheet ():
63
- with pytest .raises (
64
- css_inline .InlineError , match = "Missing stylesheet file: tests/missing.css"
65
- ):
61
+ with pytest .raises (css_inline .InlineError , match = "Missing stylesheet file: tests/missing.css" ):
66
62
css_inline .inline (
67
63
"""<html>
68
64
<head>
@@ -198,18 +194,17 @@ def test_cache():
198
194
color: blue;
199
195
}
200
196
"""
201
- EXPECTED_INLINED_FRAGMENT = '<main>\n <h1 style="color: blue;">Hello</h1>\n <section>\n <p style="color: red;">who am i</p>\n </section>\n </main>'
197
+ EXPECTED_INLINED_FRAGMENT = (
198
+ '<main>\n <h1 style="color: blue;">Hello</h1>\n <section>\n <p style="color: red;">who am i</p>\n </section>\n </main>'
199
+ )
202
200
203
201
204
202
def test_inline_fragment ():
205
203
assert css_inline .inline_fragment (FRAGMENT , CSS ) == EXPECTED_INLINED_FRAGMENT
206
204
207
205
208
206
def test_inline_fragment_method ():
209
- assert (
210
- css_inline .CSSInliner ().inline_fragment (FRAGMENT , CSS )
211
- == EXPECTED_INLINED_FRAGMENT
212
- )
207
+ assert css_inline .CSSInliner ().inline_fragment (FRAGMENT , CSS ) == EXPECTED_INLINED_FRAGMENT
213
208
214
209
215
210
def test_inline_many_fragments ():
@@ -220,19 +215,15 @@ def test_inline_many_fragments():
220
215
221
216
222
217
def test_inline_many_fragments_method ():
223
- assert css_inline .CSSInliner ().inline_many_fragments (
224
- [FRAGMENT , FRAGMENT ], [CSS , CSS ]
225
- ) == [
218
+ assert css_inline .CSSInliner ().inline_many_fragments ([FRAGMENT , FRAGMENT ], [CSS , CSS ]) == [
226
219
EXPECTED_INLINED_FRAGMENT ,
227
220
EXPECTED_INLINED_FRAGMENT ,
228
221
]
229
222
230
223
231
224
@pytest .mark .parametrize ("size" , (0 , - 1 , "foo" ))
232
225
def test_invalid_cache (size ):
233
- with pytest .raises (
234
- ValueError , match = "Cache size must be an integer greater than zero"
235
- ):
226
+ with pytest .raises (ValueError , match = "Cache size must be an integer greater than zero" ):
236
227
css_inline .StylesheetCache (size = size )
237
228
238
229
0 commit comments