Summary
This is a bit of a niche issue, sorry, but when testing a GDALDataset, you need to keep the dataset in scope to avoid segfaults. This means you have to construct a fixture like this to give you a vector layer for testing with.
@pytest.fixture
def lyr1(self, fields, srs_wgs84):
"""Return a polygon layer for testing."""
ds = self.create_temp_vector(lyr_names=["lyr1"], fields=fields, srs=srs_wgs84)
lyr = ds.GetLayer()
yield lyr
Once the layer goes out of scope, the dataset (ds) can be closed. If you return lyr, the ds will close and be garbage collected and you will get a segfault when you try and use the layer.
Feel free to close this issue as a Won't Fix, but I thought it was worth raising just in case. We can always noqa that line to keep Ruff quiet.
Version
No response
Summary
This is a bit of a niche issue, sorry, but when testing a GDALDataset, you need to keep the dataset in scope to avoid segfaults. This means you have to construct a fixture like this to give you a vector layer for testing with.
Once the layer goes out of scope, the dataset (
ds) can be closed. If you returnlyr, thedswill close and be garbage collected and you will get a segfault when you try and use the layer.Feel free to close this issue as a Won't Fix, but I thought it was worth raising just in case. We can always
noqathat line to keep Ruff quiet.Version
No response