-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconftest.py
More file actions
48 lines (34 loc) · 1.62 KB
/
Copy pathconftest.py
File metadata and controls
48 lines (34 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
Configuration file for pytest
"""
# import pytest
import warnings
import logging
import matplotlib
import platform
import pathlib
import sys
# Suppress matplotlib warnings during tests. See
# https://stackoverflow.com/questions/55109716/c-argument-looks-like-a-single-numeric-rgb-or-rgba-sequence
# from matplotlib.axes._axes import _log as matplotlib_axes_logger
# matplotlib_axes_logger.setLevel('ERROR')
matplotlib.use("svg") # set to common backend so will run ci with fewer dependencies
warnings.filterwarnings("ignore") # not sure what this does
# Raise the logging threshold, to reduce extraneous output during tests
LOG = logging.getLogger("mass")
LOG.setLevel(logging.ERROR)
def windows_monkey_patch_to_use_utf8_by_default_for_pathlib_read_text_otherwise_we_get_errors_in_test_mkdocs():
"Apparently, doctests fail on Windows without re-encoding path text. Or something like that."
os_type = platform.system()
if os_type != "Windows":
return
_original_read_text = pathlib.Path.read_text
if sys.version_info >= (3, 13):
def _utf8_read_text(self, encoding=None, errors=None, newline=None):
return _original_read_text(self, encoding=encoding or "utf-8", errors=errors, newline=newline)
else:
# python 3.12 and below don't accept the newline argument
def _utf8_read_text(self, encoding=None, errors=None, newline=None):
return _original_read_text(self, encoding=encoding or "utf-8", errors=errors)
pathlib.Path.read_text = _utf8_read_text
windows_monkey_patch_to_use_utf8_by_default_for_pathlib_read_text_otherwise_we_get_errors_in_test_mkdocs()