code: def testdata_generator():
      """Helper function to create test data sets for ideally all supported drivers"""
  
      def get_schema(driver):
          special_schemas = {
              "CSV": {
                  "geometry": None,
                  "properties": {"position": "int"},
              },
              "BNA": {"geometry": "Point", "properties": {}},
              "DXF": {
                  "properties": {
                      "Layer": "str",
                      "SubClasses": "str",
                      "Linetype": "str",
                      "EntityHandle": "str",
                      "Text": "str",
                  },
                  "geometry": "Point",
              },
              "GPX": {
                  "geometry": "Point",
                  "properties": {"ele": "float", "time": "datetime"},
              },
              "GPSTrackMaker": {"properties": {}, "geometry": "Point"},
              "DGN": {"properties": {}, "geometry": "LineString"},
              "MapInfo File": {
                  "geometry": "Point",
                  "properties": {"position": "str"},
              },
          }
  
          return special_schemas.get(
              driver,
              {"geometry": "Point", "properties": {"position": "int"}},
          )
  
      def get_crs(driver):
          special_crs = {"MapInfo File": CRS.from_epsg(4326)}
          return special_crs.get(driver, None)
  
      def get_records(driver, range):
          special_records1 = {
              "CSV": [
                  Feature.from_dict(
                      **{
                          "geometry": None,
                          "properties": {"position": i},
                      }
                  )
                  for i in range
              ],
              "BNA": [
                  Feature.from_dict(
                      **{
                          "geometry": {
                              "type": "Point",
                              "coordinates": (0.0, float(i)),
                          },
                          "properties": {},
                      }
                  )
                  for i in range
              ],
              "DXF": [
                  Feature.from_dict(
                      **{
                          "geometry": {
                              "type": "Point",
                              "coordinates": (0.0, float(i)),
                          },
                          "properties": {
                              "Layer": "0",
                              "SubClasses": "AcDbEntity:AcDbPoint",
                              "Linetype": None,
                              "EntityHandle": str(i + 20000),
                              "Text": None,
                          },
                      }
                  )
                  for i in range
              ],
              "GPX": [
                  Feature.from_dict(
                      **{
                          "geometry": {
                              "type": "Point",
                              "coordinates": (0.0, float(i)),
                          },
                          "properties": {
                              "ele": 0.0,
                              "time": "2020-03-24T16:08:40+00:00",
                          },
                      }
                  )
                  for i in range
              ],
              "GPSTrackMaker": [
                  Feature.from_dict(
                      **{
                          "geometry": {
                              "type": "Point",
                              "coordinates": (0.0, float(i)),
                          },
                          "properties": {},
                      }
                  )
                  for i in range
              ],
              "DGN": [
                  Feature.from_dict(
                      **{
                          "geometry": {
                              "type": "LineString",
                              "coordinates": [
                                  (float(i), 0.0),
                                  (0.0, 0.0),
                              ],
                          },
                          "properties": {},
                      }
                  )
                  for i in range
              ],
              "MapInfo File": [
                  Feature.from_dict(
                      **{
                          "geometry": {
                              "type": "Point",
                              "coordinates": (0.0, float(i)),
                          },
                          "properties": {"position": str(i)},
                      }
                  )
                  for i in range
              ],
              "PCIDSK": [
                  Feature.from_dict(
                      **{
                          "geometry": {
                              "type": "Point",
                              "coordinates": (0.0, float(i), 0.0),
                          },
                          "properties": {"position": i},
                      }
                  )
                  for i in range
              ],
          }
          return special_records1.get(
              driver,
              [
                  Feature.from_dict(
                      **{
                          "geometry": {
                              "type": "Point",
                              "coordinates": (0.0, float(i)),
                          },
                          "properties": {"position": i},
                      }
                  )
                  for i in range
              ],
          )
  
      def get_records2(driver, range):
          special_records2 = {
              "DGN": [
                  Feature.from_dict(
                      **{
                          "geometry": {
                              "type": "LineString",
                              "coordinates": [
                                  (float(i), 0.0),
                                  (0.0, 0.0),
                              ],
                          },
                          # TODO py39: use PEP 584 to union two dict objs
                          "properties": dict(
                              [
                                  ("Type", 4),
                                  ("Level", 0),
                                  ("GraphicGroup", 0),
                                  ("ColorIndex", 0),
                                  ("Weight", 0),
                                  ("Style", 0),
                                  ("EntityNum", None),
                                  ("MSLink", None),
                                  ("Text", None),
                              ]
                              + (
                                  [("ULink", None)]
                                  if gdal_version.at_least("3.3")
                                  else []
                              )
                          ),
                      }
                  )
                  for i in range
              ],
          }
          return special_records2.get(
              driver, get_records(driver, range)
          )
  
      def get_create_kwargs(driver):
          kwargs = {"FlatGeobuf": {"SPATIAL_INDEX": False}}
          return kwargs.get(driver, {})
  
      def test_equal(driver, val_in, val_out):
          assert val_in["geometry"] == to_dict(val_out["geometry"])
          for key in val_in["properties"]:
              if key in val_out["properties"]:
                  if driver == "FileGDB" and isinstance(
                      val_in["properties"][key], int
                  ):
                      assert str(val_in["properties"][key]) == str(
                          int(val_out["properties"][key])
                      )
                  else:
                      assert str(val_in["properties"][key]) == str(
                          val_out["properties"][key]
                      )
  
      def _testdata_generator(driver, range1, range2):
          """Generate test data and helper methods for a specific driver.
  
          Each set of generated set of records contains the position
          specified with range. These positions are either encoded as
          field or in the geometry of the record, depending of the driver
          characteristics.
  
          Parameters
          ----------
          driver : str
              Name of drive to generate tests for
          range1 : list of integer
              Range of positions for first set of records
          range2 : list of integer
              Range  of positions for second set of records
  
          Returns
          -------
          schema
              A schema for the records
          crs
              A crs for the records
          records1
              A set of records containing the positions of range1
          records2
              A set of records containing the positions of range2
          test_equal
              A function that returns True if the geometry is equal
              between the generated records and a record and if the
              properties of the generated records can be found in a
              record.
  
          """
          return (
              get_schema(driver),
              get_crs(driver),
              get_records(driver, range1),
              get_records2(driver, range2),
              test_equal,
          )
  
      return _testdata_generator
  
imports: import copy
  import json
  import os.path
  import shutil
  import tarfile
  import zipfile
  from click.testing import CliRunner
  import pytest
  import fiona
  from fiona.crs import CRS
  from fiona.env import GDALVersion
  from fiona.meta import extensions
  from fiona.model import Feature, ObjectEncoder, to_dict
label_desc: Use image node_id 34 for calling a global function with example usage: testdata_generator() and returns: _testdata_generator, special_schemas, special_crs, special_records1, special_records2, kwargs, get_schema,  get_crs,  get_records,  get_records2,  test_equal