code: def test_remove_layer(tmpdir):
      filename = str(tmpdir.join("a_filename.gpkg"))
      create_sample_data(filename, "GPKG", layer="layer1")
      create_sample_data(filename, "GPKG", layer="layer2")
      create_sample_data(filename, "GPKG", layer="layer3")
      create_sample_data(filename, "GPKG", layer="layer4")
      assert fiona.listlayers(filename) == [
          "layer1",
          "layer2",
          "layer3",
          "layer4",
      ]
  
      # remove by index
      fiona.remove(filename, layer=2)
      assert fiona.listlayers(filename) == [
          "layer1",
          "layer2",
          "layer4",
      ]
  
      # remove by name
      fiona.remove(filename, layer="layer2")
      assert fiona.listlayers(filename) == ["layer1", "layer4"]
  
      # remove by negative index
      fiona.remove(filename, layer=-1)
      assert fiona.listlayers(filename) == ["layer1"]
  
      # invalid layer name
      with pytest.raises(ValueError):
          fiona.remove(filename, layer="invalid_layer_name")
  
      # invalid layer index
      with pytest.raises(DatasetDeleteError):
          fiona.remove(filename, layer=999)
  
file_path: Fiona/tests/test_remove.py
imports: import logging
  import sys
  import os
  import itertools
  from .conftest import requires_gpkg
  import pytest
  import fiona
  from fiona.errors import DatasetDeleteError
  from fiona.model import Feature
label_desc: Use image node_id 4 for calling a global function with example usage: test_remove_layer(tmpdir) without return types