@@ -1514,6 +1514,40 @@ def test_error_engine_unavailable_fiona(tmp_path, df_points, file_path):
15141514 df_points .to_file (tmp_path / "test.gpkg" , engine = "fiona" )
15151515
15161516
1517+ def test_error_monkeypatch_engine_unavailable_pyogrio (
1518+ monkeypatch , tmp_path , df_points , file_path
1519+ ) -> None :
1520+ # monkeypatch to make pyogrio unimportable
1521+ monkeypatch .setattr (geopandas .io .file , "_import_pyogrio" , lambda : None )
1522+ monkeypatch .setattr (geopandas .io .file , "pyogrio" , None )
1523+ monkeypatch .setattr (
1524+ geopandas .io .file , "pyogrio_import_error" , "No module named 'pyogrio'"
1525+ )
1526+
1527+ with pytest .raises (ImportError , match = "No module named 'pyogrio'" ):
1528+ geopandas .read_file (file_path , engine = "pyogrio" )
1529+
1530+ with pytest .raises (ImportError , match = "No module named 'pyogrio'" ):
1531+ df_points .to_file (tmp_path / "test.gpkg" , engine = "pyogrio" )
1532+
1533+
1534+ def test_error_monkeypatch_engine_unavailable_fiona (
1535+ monkeypatch , tmp_path , df_points , file_path
1536+ ) -> None :
1537+ # monkeypatch to make fiona unimportable
1538+ monkeypatch .setattr (geopandas .io .file , "_import_fiona" , lambda : None )
1539+ monkeypatch .setattr (geopandas .io .file , "fiona" , None )
1540+ monkeypatch .setattr (
1541+ geopandas .io .file , "fiona_import_error" , "No module named 'fiona'"
1542+ )
1543+
1544+ with pytest .raises (ImportError , match = "No module named 'fiona'" ):
1545+ geopandas .read_file (file_path , engine = "fiona" )
1546+
1547+ with pytest .raises (ImportError , match = "No module named 'fiona'" ):
1548+ df_points .to_file (tmp_path / "test.gpkg" , engine = "fiona" )
1549+
1550+
15171551@PYOGRIO_MARK
15181552def test_list_layers (df_points , tmpdir ):
15191553 tempfilename = os .path .join (str (tmpdir ), "dataset.gpkg" )
0 commit comments