docstr: Test PyUnicode_AsUTF8()
docstr_tok: ["Test","PyUnicode_AsUTF8","(",")"]
code: def test_asutf8(self):
      """Test PyUnicode_AsUTF8()"""
      from _testcapi import unicode_asutf8
  
      self.assertEqual(unicode_asutf8("abc", 4), b"abc\0")
      self.assertEqual(
          unicode_asutf8("абв", 7), b"\xd0\xb0\xd0\xb1\xd0\xb2\0"
      )
      self.assertEqual(
          unicode_asutf8("\U0001f600", 5), b"\xf0\x9f\x98\x80\0"
      )
      self.assertEqual(unicode_asutf8("abc\0def", 8), b"abc\0def\0")
  
      self.assertRaises(UnicodeEncodeError, unicode_asutf8, "\ud8ff", 0)
      self.assertRaises(TypeError, unicode_asutf8, b"abc", 0)
      self.assertRaises(TypeError, unicode_asutf8, [], 0)
  
imports: import unittest
  import sys
  from test import support
  from test.support import import_helper
label_desc: Use image node_id 23 for calling the CAPITest obj's underlying member method code with example usage: obj.test_asutf8() without return types