docstr: Test transaction start/commit is called the expected number of times,
  and that the default transaction size can be overloaded. The test uses
  a custom logging handler to listen for the debug messages produced
  when the transaction is started/committed.
docstr_tok: ["Test","transaction","start\/commit","is","called","the","expected","number","of","times",",","and","that","the","default","transaction","size","can","be","overloaded",".","The","test","uses","a","custom","logging","handler","to","listen","for","the","debug","messages","produced","when","the","transaction","is","started\/committed","."]
code: def test_transaction(self, tmpdir):
      """
      Test transaction start/commit is called the expected number of times,
      and that the default transaction size can be overloaded. The test uses
      a custom logging handler to listen for the debug messages produced
      when the transaction is started/committed.
      """
      num_records = 250
      transaction_size = 100
  
      assert fiona.ogrext.DEFAULT_TRANSACTION_SIZE == 20000
      fiona.ogrext.DEFAULT_TRANSACTION_SIZE = transaction_size
      assert fiona.ogrext.DEFAULT_TRANSACTION_SIZE == transaction_size
  
      path = str(tmpdir.join("output.gpkg"))
  
      schema = {"geometry": "Point", "properties": {"value": "int"}}
  
      with fiona.open(path, "w", driver="GPKG", schema=schema) as dst:
          dst.writerecords(create_records(num_records))
  
      assert self.handler.history["Starting transaction (initial)"] == 1
      assert (
          self.handler.history["Starting transaction (intermediate)"]
          == num_records // transaction_size
      )
      assert (
          self.handler.history["Committing transaction (intermediate)"]
          == num_records // transaction_size
      )
      assert self.handler.history["Committing transaction (final)"] == 1
  
      with fiona.open(path, "r") as src:
          assert len(src) == num_records
  
file_path: Fiona/tests/test_transactions.py
imports: from collections import defaultdict
  import logging
  import os
  import pytest
  from random import uniform, randint
  import fiona
  from fiona.model import Feature
  import fiona.ogrext
  from tests.conftest import requires_gdal2
label_desc: Use image node_id 3 for calling the TestTransaction obj's underlying member method code with example usage: obj.test_transaction(tmpdir) without return types