8000 Merge pull request #19347 from anntzer/os.environ · matplotlib/matplotlib@46a4e85 · GitHub
[go: up one dir, main page]

Skip to content

Commit 46a4e85

Browse files
authored
Merge pull request #19347 from anntzer/os.environ
os.environ-related cleanups.
2 parents e0408bb + f66a299 commit 46a4e85

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

lib/matplotlib/font_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@
147147
# common application, not really useful
148148
"/usr/lib/openoffice/share/fonts/truetype/",
149149
# user fonts
150-
str(Path(os.environ.get('XDG_DATA_HOME',
151-
Path.home() / ".local/share")) / "fonts"),
150+
str((Path(os.environ.get('XDG_DATA_HOME') or Path.home() / ".local/share"))
151+
/ "fonts"),
152152
str(Path.home() / ".fonts"),
153153
]
154154
OSXFontDirectories = [

lib/matplotlib/tests/test_backend_bases.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import matplotlib.pyplot as plt
99
import matplotlib.transforms as transforms
1010
import matplotlib.path as path
11-
import os
1211
import numpy as np
1312
import pytest
1413

@@ -75,7 +74,7 @@ def test_canvas_change():
7574
def test_non_gui_warning(monkeypatch):
7675
plt.subplots()
7776

78-
monkeypatch.setitem(os.environ, "DISPLAY", ":999")
77+
monkeypatch.setenv("DISPLAY", ":999")
7978

8079
with pytest.warns(UserWarning) as rec:
8180
plt.show()

lib/matplotlib/tests/test_backend_pgf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def test_xelatex():
122122
@pytest.mark.backend('pgf')
123123
@image_comparison(['pgf_pdflatex.pdf'], style='default')
124124
def test_pdflatex():
125-
if os.environ.get('APPVEYOR', False):
125+
if os.environ.get('APPVEYOR'):
126126
pytest.xfail("pdflatex test does not work on appveyor due to missing "
127127
"LaTeX fonts")
128128

lib/matplotlib/tests/test_font_manager.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ def test_user_fonts_linux(tmpdir, monkeypatch):
170170

171171
@pytest.mark.skipif(sys.platform != 'win32', reason='Windows only')
172172
def test_user_fonts_win32():
173-
if not (os.environ.get('APPVEYOR', False) or
174-
os.environ.get('TF_BUILD', False)):
173+
if not (os.environ.get('APPVEYOR') or os.environ.get('TF_BUILD')):
175174
pytest.xfail("This test should only run on CI (appveyor or azure) "
176175
"as the developer's font directory should remain "
177176
"unchanged.")

setupext.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def get_and_extract_tarball(urls, sha, dirname):
179179

180180

181181
# matplotlib build options, which can be altered using setup.cfg
182-
setup_cfg = os.environ.get('MPLSETUPCFG', 'setup.cfg')
182+
setup_cfg = os.environ.get('MPLSETUPCFG') or 'setup.cfg'
183183
config = configparser.ConfigParser()
184184
if os.path.exists(setup_cfg):
185185
config.read(setup_cfg)
@@ -213,7 +213,7 @@ def get_pkg_config():
213213
"""
214214
if sys.platform == 'win32':
215215
return None
216-
pkg_config = os.environ.get('PKG_CONFIG', 'pkg-config')
216+
pkg_config = os.environ.get('PKG_CONFIG') or 'pkg-config'
217217
if shutil.which(pkg_config) is None:
218218
print(
219219
"IMPORTANT WARNING:\n"

0 commit comments

Comments
 (0)
0