docstr: Test PyUnicode_DecodeUTF8Stateful()
docstr_tok: ["Test","PyUnicode_DecodeUTF8Stateful","(",")"]
code: def test_decodeutf8stateful(self):
      """Test PyUnicode_DecodeUTF8Stateful()"""
      decodeutf8stateful = _testcapi.unicode_decodeutf8stateful
  
      for s in ["abc", "\xa1\xa2", "\u4f60\u597d", "a\U0001f600"]:
          b = s.encode("utf-8")
          self.assertEqual(decodeutf8stateful(b), (s, len(b)))
          self.assertEqual(decodeutf8stateful(b, "strict"), (s, len(b)))
  
      self.assertRaises(UnicodeDecodeError, decodeutf8stateful, b"\x80")
      self.assertRaises(UnicodeDecodeError, decodeutf8stateful, b"\xc0")
      self.assertRaises(UnicodeDecodeError, decodeutf8stateful, b"\xff")
      self.assertEqual(decodeutf8stateful(b"a\xf0\x9f"), ("a", 1))
      self.assertEqual(
          decodeutf8stateful(b"a\xf0\x9f", "replace"), ("a", 1)
      )
      self.assertRaises(
          UnicodeDecodeError, decodeutf8stateful, b"a\xf0\x9fb"
      )
      self.assertEqual(
          decodeutf8stateful(b"a\xf0\x9fb", "replace"), ("a\ufffdb", 4)
      )
  
      self.assertRaises(
          LookupError, decodeutf8stateful, b"a\x80", "foo"
      )
  
imports: import unittest
  import sys
  from test.support import import_helper
label_desc: Use image node_id 5 for calling the CAPITest obj's underlying member method code with example usage: obj.test_decodeutf8stateful() without return types