@@ -24,7 +24,6 @@ def setup():
2424 # from another directory we need to chdir()
2525 os .chdir (execution_path ('.' ))
2626
27-
2827def call (cmd , silent = False ):
2928 stdin , stderr = Popen (cmd , shell = True , stdout = PIPE ,
3029 stderr = PIPE ).communicate ()
@@ -129,11 +128,13 @@ def drop_imported(tabname, overview):
129128
130129
131130def compare_images (expected , im ):
131+ cur_dir = os .path .dirname (os .path .realpath (__file__ ))
132132 expected = os .path .join (
133133 os .path .dirname (expected ),
134134 os .path .basename (expected ).replace (
135135 ':' ,
136136 '_' ))
137+ expected = os .path .join (cur_dir , expected )
137138 if not os .path .exists (expected ) or os .environ .get ('UPDATE' ):
138139 print ('generating expected image %s' % expected )
139140 im .save (expected , 'png32' )
@@ -243,7 +244,7 @@ def _test_dataraster_16bsi_rendering(lbl, overview, rescale, clip):
243244
244245 def _test_dataraster_16bsi (lbl , tilesize , constraint , overview ):
245246 import_raster (
246- './ test/data/raster/dataraster-small.tif' ,
247+ os . path . join ( os . path . dirname ( os . path . realpath ( __file__ )), '../../ test/data/raster/dataraster-small.tif') ,
247248 'dataRaster' ,
248249 tilesize ,
249250 constraint ,
@@ -268,13 +269,13 @@ def test_dataraster_16bsi():
268269 _test_dataraster_16bsi (
269270 'data_16bsi' , tilesize , constraint , overview )
270271
271- # river.tiff, RGBA 8BUI
272+ # # river.tiff, RGBA 8BUI
272273 def _test_rgba_8bui_rendering (lbl , overview , rescale , clip ):
273274 if rescale :
274275 lbl += ' Sc'
275276 if clip :
276277 lbl += ' Cl'
277- ds = mapnik .PgRaster (dbname = MAPNIK_TEST_DBNAME , table = '(select * from "River") foo' ,
278+ ds = mapnik .PgRaster (dbname = MAPNIK_TEST_DBNAME , table = '(select * from "River" order by rid ) foo' ,
278279 use_overviews = 1 if overview else 0 ,
279280 prescale_rasters = rescale , clip_rasters = clip )
280281 fs = iter (ds )
@@ -312,7 +313,7 @@ def _test_rgba_8bui_rendering(lbl, overview, rescale, clip):
312313 mapnik .render (mm , im )
313314 lap = time .time () - t0
314315 log ('T ' + str (lap ) + ' -- ' + lbl + ' E:full' )
315- expected = './test/python_tests/ images/support/pgraster/%s-%s-%s-%s-box1.png' % (
316+ expected = './images/support/pgraster/%s-%s-%s-%s-box1.png' % (
316317 lyr .name , lbl , overview , clip )
317318 compare_images (expected , im )
318319 # no data
@@ -337,7 +338,7 @@ def _test_rgba_8bui_rendering(lbl, overview, rescale, clip):
337338 mapnik .render (mm , im )
338339 lap = time .time () - t0
339340 log ('T ' + str (lap ) + ' -- ' + lbl + ' E:1/10' )
340- expected = './test/python_tests/ images/support/pgraster/%s-%s-%s-%s-box2.png' % (
341+ expected = './images/support/pgraster/%s-%s-%s-%s-box2.png' % (
341342 lyr .name , lbl , overview , clip )
342343 compare_images (expected , im )
343344 # no data
@@ -356,7 +357,7 @@ def _test_rgba_8bui_rendering(lbl, overview, rescale, clip):
356357
357358 def _test_rgba_8bui (lbl , tilesize , constraint , overview ):
358359 import_raster (
359- './ test/data/raster/river.tiff' ,
360+ os . path . join ( os . path . dirname ( os . path . realpath ( __file__ )), '../../ test/data/raster/river.tiff') ,
360361 'River' ,
361362 tilesize ,
362363 constraint ,
@@ -379,22 +380,22 @@ def test_rgba_8bui():
379380 _test_rgba_8bui (
380381 'rgba_8bui' , tilesize , constraint , overview )
381382
382- # nodata-edge.tif, RGB 8BUI
383+ # # nodata-edge.tif, RGB 8BUI
383384 def _test_rgb_8bui_rendering (lbl , tnam , overview , rescale , clip ):
384385 if rescale :
385386 lbl += ' Sc'
386387 if clip :
387388 lbl += ' Cl'
388- ds = mapnik .PgRaster (dbname = MAPNIK_TEST_DBNAME , table = tnam ,
389+ ds = mapnik .PgRaster (dbname = MAPNIK_TEST_DBNAME , table = f'(select * from " { tnam } " order by rid) foo' ,
389390 use_overviews = 1 if overview else 0 ,
390391 prescale_rasters = rescale , clip_rasters = clip )
391392 fs = iter (ds )
392393 feature = next (fs )
393394 assert feature ['rid' ] == 1
394395 lyr = mapnik .Layer ('rgba_8bui' )
395396 lyr .datasource = ds
396- expenv = mapnik .Box2d (- 12329035.7652168 , 4508650.39854396 ,
397- - 12328653.0279471 , 4508957.34625536 )
397+ expenv = mapnik .Box2d (- 12329035.765216826 , 4508650.398543958 ,
398+ - 12328653.027947055 , 4508957.346255356 )
398399 env = lyr .envelope ()
399400 # As the input size is a prime number both horizontally
400401 # and vertically, we expect the extent of the overview
@@ -424,7 +425,7 @@ def _test_rgb_8bui_rendering(lbl, tnam, overview, rescale, clip):
424425 mapnik .render (mm , im )
425426 lap = time .time () - t0
426427 log ('T ' + str (lap ) + ' -- ' + lbl + ' E:full' )
427- expected = './test/python_tests/ images/support/pgraster/%s-%s-%s-%s-%s-box1.png' % (
428+ expected = './images/support/pgraster/%s-%s-%s-%s-%s-box1.png' % (
428429 lyr .name , tnam , lbl , overview , clip )
429430 compare_images (expected , im )
430431 # no data
@@ -447,7 +448,7 @@ def _test_rgb_8bui_rendering(lbl, tnam, overview, rescale, clip):
447448 mapnik .render (mm , im )
448449 lap = time .time () - t0
449450 log ('T ' + str (lap ) + ' -- ' + lbl + ' E:1/10' )
450- expected = './test/python_tests/ images/support/pgraster/%s-%s-%s-%s-%s-box2.png' % (
451+ expected = 'images/support/pgraster/%s-%s-%s-%s-%s-box2.png' % (
451452 lyr .name , tnam , lbl , overview , clip )
452453 compare_images (expected , im )
453454 # no data
@@ -466,7 +467,7 @@ def _test_rgb_8bui_rendering(lbl, tnam, overview, rescale, clip):
466467 def _test_rgb_8bui (lbl , tilesize , constraint , overview ):
467468 tnam = 'nodataedge'
468469 import_raster (
469- './ test/data/raster/nodata-edge.tif' ,
470+ os . path . join ( os . path . dirname ( os . path . realpath ( __file__ )), '../../ test/data/raster/nodata-edge.tif') ,
470471 tnam ,
471472 tilesize ,
472473 constraint ,
@@ -480,7 +481,7 @@ def _test_rgb_8bui(lbl, tilesize, constraint, overview):
480481 for prescale in [0 , 1 ]:
481482 for clip in [0 , 1 ]:
482483 _test_rgb_8bui_rendering (lbl , tnam , overview , prescale , clip )
483- # drop_imported(tnam, overview)
484+ drop_imported (tnam , overview )
484485
485486 def test_rgb_8bui ():
486487 for tilesize in ['64x64' ]:
@@ -529,10 +530,10 @@ def _test_grayscale_subquery(lbl, pixtype, value):
529530 lyr .datasource = ds
530531 expenv = mapnik .Box2d (0 , 0 , 14 , 14 )
531532 env = lyr .envelope ()
532- assert env .minx == expenv .minx #, places=0)
533- assert env .miny == expenv .miny #, places=0)
534- assert env .maxx == expenv .maxx #, places=0)
535- assert env .maxy == expenv .maxy #, places=0)
533+ assert env .minx == expenv .minx
534+ assert env .miny == expenv .miny
535+ assert env .maxx == expenv .maxx
536+ assert env .maxy == expenv .maxy
536537 mm = mapnik .Map (15 , 15 )
537538 style = mapnik .Style ()
538539 sym = mapnik .RasterSymbolizer ()
@@ -548,7 +549,7 @@ def _test_grayscale_subquery(lbl, pixtype, value):
548549 mapnik .render (mm , im )
549550 lap = time .time () - t0
550551 log ('T ' + str (lap ) + ' -- ' + lbl + ' E:full' )
551- expected = './test/python_tests/ images/support/pgraster/%s-%s-%s-%s.png' % (
552+ expected = 'images/support/pgraster/%s-%s-%s-%s.png' % (
552553 lyr .name , lbl , pixtype , value )
553554 compare_images (expected , im )
554555 h = format (value , '02x' )
@@ -667,7 +668,7 @@ def _test_data_subquery(lbl, pixtype, value):
667668 mapnik .render (mm , im )
668669 lap = time .time () - t0
669670 log ('T ' + str (lap ) + ' -- ' + lbl + ' E:full' )
670- expected = './test/python_tests/ images/support/pgraster/%s-%s-%s-%s.png' % (
671+ expected = 'images/support/pgraster/%s-%s-%s-%s.png' % (
671672 lyr .name , lbl , pixtype , value )
672673 compare_images (expected , im )
673674
@@ -785,11 +786,11 @@ def _test_rgba_subquery(lbl, pixtype, r, g, b, a, g1, b1):
785786 mapnik .render (mm , im )
786787 lap = time .time () - t0
787788 log ('T ' + str (lap ) + ' -- ' + lbl + ' E:full' )
788- expected = './test/python_tests/ images/support/pgraster/%s-%s-%s-%s-%s-%s-%s-%s-%s.png' % (
789+ expected = 'images/support/pgraster/%s-%s-%s-%s-%s-%s-%s-%s-%s.png' % (
789790 lyr .name , lbl , pixtype , r , g , b , a , g1 , b1 )
790791 compare_images (expected , im )
791- hex_v = format (r << 24 | g << 16 | b << 8 | a , '08x' ).encode ()
792- hex_a = format (r << 24 | g1 << 16 | b << 8 | a , '08x' ).encode ()
792+ hex_v = format (r << 24 | g << 16 | b << 8 | a , '08x' ).encode ()
793+ hex_a = format (r << 24 | g1 << 16 | b << 8 | a , '08x' ).encode ()
793794 hex_b = format (r << 24 | g << 16 | b1 << 8 | a , '08x' ).encode ()
794795 assert hexlify (im .view (3 , 3 , 1 , 1 ).to_string ()) == hex_v
795796 assert hexlify (im .view (8 , 3 , 1 , 1 ).to_string ()) == hex_v
@@ -812,11 +813,11 @@ def test_rgba_8bui_subquery():
812813 255 ,
813814 255 )
814815
815- # def test_rgba_16bui_subquery():
816- # _test_rgba_subquery('rgba_16bui_subquery', '16BUI', 65535, 0, 0, 65535, 65535, 65535)
816+ #def test_rgba_16bui_subquery():
817+ # _test_rgba_subquery('rgba_16bui_subquery', '16BUI', 65535, 0, 0, 65535, 65535, 65535)
817818
818- # def test_rgba_32bui_subquery():
819- # _test_rgba_subquery('rgba_32bui_subquery', '32BUI')
819+ #def test_rgba_32bui_subquery():
820+ # _test_rgba_subquery('rgba_32bui_subquery', '32BUI')
820821
821822 atexit .register (postgis_takedown )
822823
0 commit comments