MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_svg_default_metadata

Function test_svg_default_metadata

lib/matplotlib/tests/test_backend_svg.py:391–422  ·  view source on GitHub ↗
(monkeypatch)

Source from the content-addressed store, hash-verified

389
390
391def test_svg_default_metadata(monkeypatch):
392 # Values have been predefined for 'Creator', 'Date', 'Format', and 'Type'.
393 monkeypatch.setenv('SOURCE_DATE_EPOCH', '19680801')
394
395 fig, ax = plt.subplots()
396 with BytesIO() as fd:
397 fig.savefig(fd, format='svg')
398 buf = fd.getvalue().decode()
399
400 # Creator
401 assert mpl.__version__ in buf
402 # Date
403 assert '1970-08-16' in buf
404 # Format
405 assert 'image/svg+xml' in buf
406 # Type
407 assert 'StillImage' in buf
408
409 # Now make sure all the default metadata can be cleared.
410 with BytesIO() as fd:
411 fig.savefig(fd, format='svg', metadata={'Date': None, 'Creator': None,
412 'Format': None, 'Type': None})
413 buf = fd.getvalue().decode()
414
415 # Creator
416 assert mpl.__version__ not in buf
417 # Date
418 assert '1970-08-16' not in buf
419 # Format
420 assert 'image/svg+xml' not in buf
421 # Type
422 assert 'StillImage' not in buf
423
424
425def test_svg_clear_default_metadata(monkeypatch):

Callers

nothing calls this directly

Calls 2

subplotsMethod · 0.45
savefigMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…