Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions lib/matplotlib/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,26 @@ def subprocess_run_helper(func, *args, timeout, extra_env=None):
f"_module = importlib.util.module_from_spec(_spec);"
f"_spec.loader.exec_module(_module);"
f"_module.{target}()",
*args
*args,
],
env={**os.environ, "SOURCE_DATE_EPOCH": "0", **(extra_env or {})},
timeout=timeout, check=True,
env={
**os.environ,
"SOURCE_DATE_EPOCH": "0",
# subprocess_run_helper sets SOURCE_DATE_EPOCH=0 above, so for a dirty tree,
# the version will have the date 19700101 which breaks pickle tests with a
# warning if the working tree is dirty.
#
# This will also avoid at least one additional subprocess call for
# setuptools-scm query git, so we tell the subprocess what version
# to report as the test process.
"SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MATPLOTLIB": mpl.__version__,
**(extra_env or {}),
},
timeout=timeout,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
text=True,
)
return proc

Expand Down
10 changes: 1 addition & 9 deletions lib/matplotlib/tests/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,7 @@ def test_pickle_load_from_subprocess(fig_test, fig_ref, tmp_path):
proc = subprocess_run_helper(
_pickle_load_subprocess,
timeout=60,
extra_env={
"PICKLE_FILE_PATH": str(fp),
"MPLBACKEND": "Agg",
# subprocess_run_helper will set SOURCE_DATE_EPOCH=0, so for a dirty tree,
# the version will have the date 19700101. As we aren't trying to test the
# version compatibility warning, force setuptools-scm to use the same
# version as us.
"SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MATPLOTLIB": mpl.__version__,
},
extra_env={"PICKLE_FILE_PATH": str(fp), "MPLBACKEND": "Agg"},
)

loaded_fig = pickle.loads(ast.literal_eval(proc.stdout))
Expand Down
Loading