code: def test_pack_into_fn(self):
      test_string = b"Reykjavik rocks, eow!"
      writable_buf = array.array("b", b" " * 100)
      fmt = "21s"
      pack_into = lambda *args: struct.pack_into(fmt, *args)
  
      # Test without offset.
      pack_into(writable_buf, 0, test_string)
      from_buf = writable_buf.tobytes()[: len(test_string)]
      self.assertEqual(from_buf, test_string)
  
      # Test with offset.
      pack_into(writable_buf, 10, test_string)
      from_buf = writable_buf.tobytes()[: len(test_string) + 10]
      self.assertEqual(from_buf, test_string[:10] + test_string)
  
      # Go beyond boundaries.
      small_buf = array.array("b", b" " * 10)
      self.assertRaises(
          (ValueError, struct.error),
          pack_into,
          small_buf,
          0,
          test_string,
      )
      self.assertRaises(
          (ValueError, struct.error),
          pack_into,
          small_buf,
          2,
          test_string,
      )
  
imports: from collections import abc
  import array
  import gc
  import math
  import operator
  import unittest
  import struct
  import sys
  import weakref
  from test import support
  from test.support import import_helper
  from test.support.script_helper import assert_python_ok
label_desc: Use image node_id 13 for calling the StructTest obj's underlying member method code with example usage: obj.test_pack_into_fn() without return types