| 389 | |
| 390 | |
| 391 | def 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 | |
| 425 | def test_svg_clear_default_metadata(monkeypatch): |