@@ -82,10 +82,23 @@ class HasEnum:
82
82
choice : Choices
83
83
84
84
85
+
86
+
85
87
class UnitTests (parameterized .TestCase ):
88
+
86
89
@parameterized .named_parameters (
87
- ["PIL" , PIL .Image .open (TEST_PNG_PATH )],
88
90
["RGBA" , PIL .Image .fromarray (np .zeros ([6 , 6 , 4 ], dtype = np .uint8 ))],
91
+ ["RGB" , PIL .Image .fromarray (np .zeros ([6 , 6 , 3 ], dtype = np .uint8 ))],
92
+ ["P" , PIL .Image .fromarray (np .zeros ([6 , 6 , 3 ], dtype = np .uint8 )).convert ("P" )],
93
+ )
94
+ def test_numpy_to_blob (self , image ):
95
+ blob = content_types .image_to_blob (image )
96
+ self .assertIsInstance (blob , protos .Blob )
97
+ self .assertEqual (blob .mime_type , "image/webp" )
98
+ self .assertStartsWith (blob .data , b"RIFF \x00 \x00 \x00 WEBPVP8L" )
99
+
100
+ @parameterized .named_parameters (
101
+ ["PIL" , PIL .Image .open (TEST_PNG_PATH )],
89
102
["IPython" , IPython .display .Image (filename = TEST_PNG_PATH )],
90
103
)
91
104
def test_png_to_blob (self , image ):
@@ -96,7 +109,6 @@ def test_png_to_blob(self, image):
96
109
97
110
@parameterized .named_parameters (
98
111
["PIL" , PIL .Image .open (TEST_JPG_PATH )],
99
- ["RGB" , PIL .Image .fromarray (np .zeros ([6 , 6 , 3 ], dtype = np .uint8 ))],
100
112
["IPython" , IPython .display .Image (filename = TEST_JPG_PATH )],
101
113
)
102
114
def test_jpg_to_blob (self , image ):
@@ -107,7 +119,6 @@ def test_jpg_to_blob(self, image):
107
119
108
120
@parameterized .named_parameters (
109
121
["PIL" , PIL .Image .open (TEST_GIF_PATH )],
110
- ["P" , PIL .Image .fromarray (np .zeros ([6 , 6 , 3 ], dtype = np .uint8 )).convert ("P" )],
111
122
["IPython" , IPython .display .Image (filename = TEST_GIF_PATH )],
112
123
)
113
124
def test_gif_to_blob (self , image ):
0 commit comments