@@ -53,7 +53,7 @@ def test_expected_encodings(setup):
5353 im .save (expected , opt )
5454 else :
5555 im .save (actual , opt )
56- assert mapnik .Image .open (actual ).tostring ('png32' ) == mapnik .Image .open (expected ).tostring ('png32' ), '%s (actual) not == to %s (expected)' % (actual , expected )
56+ assert mapnik .Image .open (actual ).to_string ('png32' ) == mapnik .Image .open (expected ).to_string ('png32' ), '%s (actual) not == to %s (expected)' % (actual , expected )
5757
5858 # solid image
5959 im .fill (mapnik .Color ('green' ))
@@ -65,7 +65,7 @@ def test_expected_encodings(setup):
6565 im .save (expected , opt )
6666 else :
6767 im .save (actual , opt )
68- assert mapnik .Image .open (actual ).tostring ('png32' ) == mapnik .Image .open (expected ).tostring ('png32' ), '%s (actual) not == to %s (expected)' % (actual , expected )
68+ assert mapnik .Image .open (actual ).to_string ('png32' ) == mapnik .Image .open (expected ).to_string ('png32' ), '%s (actual) not == to %s (expected)' % (actual , expected )
6969
7070 # aerial
7171 im = mapnik .Image .open ('./images/support/transparency/aerial_rgba.png' )
@@ -77,7 +77,7 @@ def test_expected_encodings(setup):
7777 im .save (expected , opt )
7878 else :
7979 im .save (actual , opt )
80- assert mapnik .Image .open (actual ).tostring ('png32' ) == mapnik .Image .open (expected ).tostring ('png32' ), '%s (actual) not == to %s (expected)' % (actual , expected )
80+ assert mapnik .Image .open (actual ).to_string ('png32' ) == mapnik .Image .open (expected ).to_string ('png32' ), '%s (actual) not == to %s (expected)' % (actual , expected )
8181
8282 def test_transparency_levels ():
8383 # create partial transparency image
@@ -100,96 +100,96 @@ def test_transparency_levels():
100100 format = 'png8:m=o:t=0'
101101 im .save (t0 , format )
102102 im_in = mapnik .Image .open (t0 )
103- t0_len = len (im_in .tostring (format ))
104- assert t0_len == len (mapnik .Image .open ('images/support/transparency/white0.png' ).tostring (format ))
103+ t0_len = len (im_in .to_string (format ))
104+ assert t0_len == len (mapnik .Image .open ('images/support/transparency/white0.png' ).to_string (format ))
105105 format = 'png8:m=o:t=1'
106106 im .save (t1 , format )
107107 im_in = mapnik .Image .open (t1 )
108- t1_len = len (im_in .tostring (format ))
109- assert len (im .tostring (format )) == len (mapnik .Image .open ('images/support/transparency/white1.png' ).tostring (format ))
108+ t1_len = len (im_in .to_string (format ))
109+ assert len (im .to_string (format )) == len (mapnik .Image .open ('images/support/transparency/white1.png' ).to_string (format ))
110110 format = 'png8:m=o:t=2'
111111 im .save (t2 , format )
112112 im_in = mapnik .Image .open (t2 )
113- t2_len = len (im_in .tostring (format ))
114- assert len (im .tostring (format )) == len (mapnik .Image .open ('images/support/transparency/white2.png' ).tostring (format ))
113+ t2_len = len (im_in .to_string (format ))
114+ assert len (im .to_string (format )) == len (mapnik .Image .open ('images/support/transparency/white2.png' ).to_string (format ))
115115 assert t0_len < t1_len < t2_len
116116
117117 # hextree
118118 format = 'png8:m=h:t=0'
119119 im .save (t0 , format )
120120 im_in = mapnik .Image .open (t0 )
121- t0_len = len (im_in .tostring (format ))
122- assert t0_len == len (mapnik .Image .open ('images/support/transparency/white0.png' ).tostring (format ))
121+ t0_len = len (im_in .to_string (format ))
122+ assert t0_len == len (mapnik .Image .open ('images/support/transparency/white0.png' ).to_string (format ))
123123 format = 'png8:m=h:t=1'
124124 im .save (t1 , format )
125125 im_in = mapnik .Image .open (t1 )
126- t1_len = len (im_in .tostring (format ))
127- assert len (im .tostring (format )) == len (mapnik .Image .open ('images/support/transparency/white1.png' ).tostring (format ))
126+ t1_len = len (im_in .to_string (format ))
127+ assert len (im .to_string (format )) == len (mapnik .Image .open ('images/support/transparency/white1.png' ).to_string (format ))
128128 format = 'png8:m=h:t=2'
129129 im .save (t2 , format )
130130 im_in = mapnik .Image .open (t2 )
131- t2_len = len (im_in .tostring (format ))
132- assert len (im .tostring (format )) == len (mapnik .Image .open ('images/support/transparency/white2.png' ).tostring (format ))
131+ t2_len = len (im_in .to_string (format ))
132+ assert len (im .to_string (format )) == len (mapnik .Image .open ('images/support/transparency/white2.png' ).to_string (format ))
133133 assert t0_len < t1_len < t2_len
134134
135135 def test_transparency_levels_aerial ():
136136 im = mapnik .Image .open ('../data/images/12_654_1580.png' )
137137 im_in = mapnik .Image .open (
138138 './images/support/transparency/aerial_rgba.png' )
139- assert len (im .tostring ('png8' )) == len (im_in .tostring ('png8' ))
140- assert len (im .tostring ('png32' )) == len (im_in .tostring ('png32' ))
139+ assert len (im .to_string ('png8' )) == len (im_in .to_string ('png8' ))
140+ assert len (im .to_string ('png32' )) == len (im_in .to_string ('png32' ))
141141
142142 im_in = mapnik .Image .open (
143143 './images/support/transparency/aerial_rgb.png' )
144- assert len (im .tostring ('png32' )) == len (im_in .tostring ('png32' ))
145- assert len (im .tostring ('png32:t=0' )) == len (im_in .tostring ('png32:t=0' ))
146- assert not len (im .tostring ('png32:t=0' )) == len (im_in .tostring ('png32' ))
147- assert len (im .tostring ('png8' )) == len (im_in .tostring ('png8' ))
148- assert len (im .tostring ('png8:t=0' )) == len (im_in .tostring ('png8:t=0' ))
144+ assert len (im .to_string ('png32' )) == len (im_in .to_string ('png32' ))
145+ assert len (im .to_string ('png32:t=0' )) == len (im_in .to_string ('png32:t=0' ))
146+ assert not len (im .to_string ('png32:t=0' )) == len (im_in .to_string ('png32' ))
147+ assert len (im .to_string ('png8' )) == len (im_in .to_string ('png8' ))
148+ assert len (im .to_string ('png8:t=0' )) == len (im_in .to_string ('png8:t=0' ))
149149 # unlike png32 paletted images without alpha will look the same even if
150150 # no alpha is forced
151- assert len (im .tostring ('png8:t=0' )) == len (im_in .tostring ('png8' ))
152- assert len (im .tostring ('png8:t=0:m=o' )) == len (im_in .tostring ('png8:m=o' ))
151+ assert len (im .to_string ('png8:t=0' )) == len (im_in .to_string ('png8' ))
152+ assert len (im .to_string ('png8:t=0:m=o' )) == len (im_in .to_string ('png8:m=o' ))
153153
154154 def test_9_colors_hextree ():
155155 expected = './images/support/encoding-opts/png8-9cols.png'
156156 im = mapnik .Image .open (expected )
157157 t0 = tmp_dir + 'png-encoding-9-colors.result-hextree.png'
158158 im .save (t0 , 'png8:m=h' )
159- assert mapnik .Image .open (t0 ).tostring () == mapnik .Image .open (expected ).tostring (), '%s (actual) not == to %s (expected)' % (t0 , expected )
159+ assert mapnik .Image .open (t0 ).to_string () == mapnik .Image .open (expected ).to_string (), '%s (actual) not == to %s (expected)' % (t0 , expected )
160160
161161 def test_9_colors_octree ():
162162 expected = './images/support/encoding-opts/png8-9cols.png'
163163 im = mapnik .Image .open (expected )
164164 t0 = tmp_dir + 'png-encoding-9-colors.result-octree.png'
165165 im .save (t0 , 'png8:m=o' )
166- assert mapnik .Image .open (t0 ).tostring () == mapnik .Image .open (expected ).tostring (), '%s (actual) not == to %s (expected)' % (t0 , expected )
166+ assert mapnik .Image .open (t0 ).to_string () == mapnik .Image .open (expected ).to_string (), '%s (actual) not == to %s (expected)' % (t0 , expected )
167167
168168 def test_17_colors_hextree ():
169169 expected = './images/support/encoding-opts/png8-17cols.png'
170170 im = mapnik .Image .open (expected )
171171 t0 = tmp_dir + 'png-encoding-17-colors.result-hextree.png'
172172 im .save (t0 , 'png8:m=h' )
173- assert mapnik .Image .open (t0 ).tostring () == mapnik .Image .open (expected ).tostring (), '%s (actual) not == to %s (expected)' % (t0 , expected )
173+ assert mapnik .Image .open (t0 ).to_string () == mapnik .Image .open (expected ).to_string (), '%s (actual) not == to %s (expected)' % (t0 , expected )
174174
175175 def test_17_colors_octree ():
176176 expected = './images/support/encoding-opts/png8-17cols.png'
177177 im = mapnik .Image .open (expected )
178178 t0 = tmp_dir + 'png-encoding-17-colors.result-octree.png'
179179 im .save (t0 , 'png8:m=o' )
180- assert mapnik .Image .open (t0 ).tostring () == mapnik .Image .open (expected ).tostring (), '%s (actual) not == to %s (expected)' % (t0 , expected )
180+ assert mapnik .Image .open (t0 ).to_string () == mapnik .Image .open (expected ).to_string (), '%s (actual) not == to %s (expected)' % (t0 , expected )
181181
182182 def test_2px_regression_hextree ():
183183 im = mapnik .Image .open ('./images/support/encoding-opts/png8-2px.A.png' )
184184 expected = './images/support/encoding-opts/png8-2px.png'
185185
186186 t0 = tmp_dir + 'png-encoding-2px.result-hextree.png'
187187 im .save (t0 , 'png8:m=h' )
188- assert mapnik .Image .open (t0 ).tostring () == mapnik .Image .open (expected ).tostring (), '%s (actual) not == to %s (expected)' % (t0 , expected )
188+ assert mapnik .Image .open (t0 ).to_string () == mapnik .Image .open (expected ).to_string (), '%s (actual) not == to %s (expected)' % (t0 , expected )
189189
190190 def test_2px_regression_octree ():
191191 im = mapnik .Image .open ('./images/support/encoding-opts/png8-2px.A.png' )
192192 expected = './images/support/encoding-opts/png8-2px.png'
193193 t0 = tmp_dir + 'png-encoding-2px.result-octree.png'
194194 im .save (t0 , 'png8:m=o' )
195- assert mapnik .Image .open (t0 ).tostring () == mapnik .Image .open (expected ).tostring (), '%s (actual) not == to %s (expected)' % (t0 , expected )
195+ assert mapnik .Image .open (t0 ).to_string () == mapnik .Image .open (expected ).to_string (), '%s (actual) not == to %s (expected)' % (t0 , expected )
0 commit comments