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

Skip to content

Commit 9d46338

Browse files
committed
Enforce stricter tests for _repr_png_.
1 parent a490278 commit 9d46338

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

lib/matplotlib/tests/test_colors.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import copy
22
import itertools
33

4+
from io import BytesIO
45
import numpy as np
6+
from PIL import Image
57
import pytest
68

79
from numpy.testing import assert_array_equal, assert_array_almost_equal
@@ -1141,6 +1143,13 @@ def test_repr_png():
11411143
cmap = plt.get_cmap('viridis')
11421144
png = cmap._repr_png_()
11431145
assert len(png) > 0
1146+
img = Image.open(BytesIO(png))
1147+
assert img.width > 0
1148+
assert img.height > 0
1149+
assert 'Title' in img.text
1150+
assert 'Description' in img.text
1151+
assert 'Author' in img.text
1152+
assert 'Software' in img.text
11441153

11451154

11461155
def test_repr_html():

0 commit comments

Comments
 (0)