code: def test_written_bytes_equals_size_in_bytes_v2():
      key = b"test"
      value = b"Super"
      headers = [("header1", b"aaa"), ("header2", b"bbb"), ("xx", None)]
      builder = DefaultRecordBatchBuilder(
          magic=2,
          compression_type=0,
          is_transactional=0,
          producer_id=-1,
          producer_epoch=-1,
          base_sequence=-1,
          batch_size=999999,
      )
  
      size_in_bytes = builder.size_in_bytes(
          0, timestamp=9999999, key=key, value=value, headers=headers
      )
  
      pos = builder.size()
      meta = builder.append(
          0, timestamp=9999999, key=key, value=value, headers=headers
      )
  
      assert builder.size() - pos == size_in_bytes
      assert meta.size == size_in_bytes
  
file_path: kafka-python/test/record/test_default_records.py
imports: from __future__ import unicode_literals
  import pytest
  from mock import patch
  import kafka.codec
  from kafka.record.default_records import DefaultRecordBatch, DefaultRecordBatchBuilder
  from kafka.errors import UnsupportedCodecError
label_desc: Use image node_id 2 for calling a global function with example usage: test_written_bytes_equals_size_in_bytes_v2() without return types