1
+ import contextlib
1
2
import json
2
3
import os
3
4
import sys
@@ -270,6 +271,7 @@ def test_write(tmpdir, naturalearth_lowres):
270
271
271
272
def test_write_gpkg (tmpdir , naturalearth_lowres ):
272
273
meta , _ , geometry , field_data = read (naturalearth_lowres )
274
+ meta .update ({"geometry_type" : "MultiPolygon" })
273
275
274
276
filename = os .path .join (str (tmpdir ), "test.gpkg" )
275
277
write (filename , geometry , field_data , driver = "GPKG" , ** meta )
@@ -456,9 +458,11 @@ def assert_equal_result(result1, result2):
456
458
assert all ([np .array_equal (f1 , f2 ) for f1 , f2 in zip (field_data1 , field_data2 )])
457
459
458
460
461
+ @pytest .mark .filterwarnings ("ignore:File /vsimem:RuntimeWarning" ) # TODO
459
462
@pytest .mark .parametrize ("driver,ext" , [("GeoJSON" , "geojson" ), ("GPKG" , "gpkg" )])
460
463
def test_read_from_bytes (tmpdir , naturalearth_lowres , driver , ext ):
461
464
meta , index , geometry , field_data = read (naturalearth_lowres )
465
+ meta .update ({"geometry_type" : "Unknown" })
462
466
filename = os .path .join (str (tmpdir ), f"test.{ ext } " )
463
467
write (filename , geometry , field_data , driver = driver , ** meta )
464
468
@@ -480,9 +484,11 @@ def test_read_from_bytes_zipped(tmpdir, naturalearth_lowres_vsi):
480
484
assert_equal_result ((meta , index , geometry , field_data ), result2 )
481
485
482
486
487
+ @pytest .mark .filterwarnings ("ignore:File /vsimem:RuntimeWarning" ) # TODO
483
488
@pytest .mark .parametrize ("driver,ext" , [("GeoJSON" , "geojson" ), ("GPKG" , "gpkg" )])
484
489
def test_read_from_file_like (tmpdir , naturalearth_lowres , driver , ext ):
485
490
meta , index , geometry , field_data = read (naturalearth_lowres )
491
+ meta .update ({"geometry_type" : "Unknown" })
486
492
filename = os .path .join (str (tmpdir ), f"test.{ ext } " )
487
493
write (filename , geometry , field_data , driver = driver , ** meta )
488
494
@@ -647,7 +653,12 @@ def test_write_float_nan_null(tmp_path, dtype):
647
653
648
654
# set to False
649
655
# by default, GDAL will skip the property for GeoJSON if the value is NaN
650
- write (fname , geometry , field_data , fields , ** meta , nan_as_null = False )
656
+ if dtype == "float32" :
657
+ ctx = pytest .warns (RuntimeWarning , match = "NaN of Infinity value found. Skipped" )
658
+ else :
659
+ ctx = contextlib .nullcontext ()
660
+ with ctx :
661
+ write (fname , geometry , field_data , fields , ** meta , nan_as_null = False )
651
662
with open (str (fname ), "r" ) as f :
652
663
content = f .read ()
653
664
assert '"properties": { }' in content
0 commit comments