Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 42259bb

Browse files
authored
Merge pull request #16556 from anntzer/psrobust
Make backend_ps test robust against timestamp changes in ghostscript.
2 parents 9cd240a + c7d4816 commit 42259bb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/matplotlib/tests/test_backend_ps.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import io
22
from pathlib import Path
3+
import re
34
import tempfile
45

56
import pytest
@@ -69,6 +70,13 @@ def test_savefig_to_stringio(format, use_log, rcParams, orientation,
6970
s_val = s_buf.getvalue().encode('ascii')
7071
b_val = b_buf.getvalue()
7172

73+
if rcParams.get("ps.usedistiller") or rcParams.get("text.usetex"):
74+
# Strip out CreationDate betcase ghostscript doesn't obey
75+
# SOURCE_DATE_EPOCH. Note that in usetex mode, we *always* call
76+
# gs_distill, even if ps.usedistiller is unset.
77+
s_val = re.sub(b"(?<=\n%%CreationDate: ).*", b"", s_val)
78+
b_val = re.sub(b"(?<=\n%%CreationDate: ).*", b"", b_val)
79+
7280
assert s_val == b_val.replace(b'\r\n', b'\n')
7381

7482

0 commit comments

Comments
 (0)