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

Skip to content

Commit 6aee70f

Browse files
committed
Further simplify SOURCE_DATE_EPOCH test.
1 parent deabbf5 commit 6aee70f

1 file changed

Lines changed: 4 additions & 14 deletions

File tree

lib/matplotlib/tests/test_determinism.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44

55
import os
6-
import re
76
import subprocess
87
import sys
98

@@ -122,7 +121,7 @@ def test_determinism_check(objects, fmt, usetex):
122121
("ps", b"%%CreationDate: Sat Jan 01 00:00:00 2000"),
123122
]
124123
)
125-
def test_determinism_source_date_epoch(fmt, string, keyword=b"CreationDate"):
124+
def test_determinism_source_date_epoch(fmt, string):
126125
"""
127126
Test SOURCE_DATE_EPOCH support. Output a document with the environment
128127
variable SOURCE_DATE_EPOCH set to 2000-01-01 00:00 UTC and check that the
@@ -133,21 +132,12 @@ def test_determinism_source_date_epoch(fmt, string, keyword=b"CreationDate"):
133132
----------
134133
fmt : {"pdf", "ps", "svg"}
135134
Output format.
136-
string : str
135+
string : bytes
137136
Timestamp string for 2000-01-01 00:00 UTC.
138-
keyword : bytes
139-
A string to look at when searching for the timestamp in the document
140-
(used in case the test fails).
141137
"""
142-
buff = subprocess.check_output(
138+
buf = subprocess.check_output(
143139
[sys.executable, "-R", "-c",
144140
f"from matplotlib.tests.test_determinism import _save_figure; "
145141
f"_save_figure('', {fmt!r})"],
146142
env={**os.environ, "SOURCE_DATE_EPOCH": "946684800"})
147-
find_keyword = re.compile(b".*" + keyword + b".*")
148-
key = find_keyword.search(buff)
149-
if key:
150-
print(key.group())
151-
else:
152-
print("Timestamp keyword (%s) not found!" % keyword)
153-
assert string in buff
143+
assert string in buf

0 commit comments

Comments
 (0)