Skip to content

Commit b9a477e

Browse files
committed
Resolve EncodingWarning in tests
1 parent a228834 commit b9a477e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tests/conftest.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
import sys
4+
import warnings
35
from pathlib import Path
46

57
import pytest
@@ -13,6 +15,14 @@
1315
else:
1416
mpl.rcParams['figure.max_open_warning'] = 0
1517

18+
if sys.version_info[:2] >= (3, 10):
19+
warnings.filterwarnings(
20+
'ignore',
21+
category=EncodingWarning, # NoQA: F821
22+
module='matplotlib.font_manager',
23+
)
24+
25+
1626
pytest_plugins = ['sphinx.testing.fixtures']
1727

1828

@@ -34,9 +44,9 @@ def content(app):
3444

3545
def _meta_tags(content, subdir=None):
3646
if subdir is None:
37-
c = (content.outdir / 'index.html').read_text()
47+
c = (content.outdir / 'index.html').read_text(encoding='utf-8')
3848
else:
39-
c = (content.outdir / subdir / 'index.html').read_text()
49+
c = (content.outdir / subdir / 'index.html').read_text(encoding='utf-8')
4050
return BeautifulSoup(c, 'html.parser').find_all('meta')
4151

4252

0 commit comments

Comments
 (0)