docstr: Test PyUnicode_FromEncodedObject()
docstr_tok: ["Test","PyUnicode_FromEncodedObject","(",")"]
code: def test_fromencodedobject(self):
      """Test PyUnicode_FromEncodedObject()"""
      fromencodedobject = _testcapi.unicode_fromencodedobject
  
      self.assertEqual(fromencodedobject(b"abc", NULL), "abc")
      self.assertEqual(fromencodedobject(b"abc", "ascii"), "abc")
      b = b"a\xc2\xa1\xe4\xbd\xa0\xf0\x9f\x98\x80"
      s = "a\xa1\u4f60\U0001f600"
      self.assertEqual(fromencodedobject(b, NULL), s)
      self.assertEqual(fromencodedobject(b, "utf-8"), s)
      self.assertEqual(
          fromencodedobject(b, "latin1"), b.decode("latin1")
      )
      self.assertRaises(
          UnicodeDecodeError, fromencodedobject, b, "ascii"
      )
      self.assertEqual(
          fromencodedobject(b, "ascii", "replace"), "a" + "\ufffd" * 9
      )
      self.assertEqual(fromencodedobject(bytearray(b), NULL), s)
      self.assertEqual(fromencodedobject(bytearray(b), "utf-8"), s)
      self.assertRaises(LookupError, fromencodedobject, b"abc", "foo")
      self.assertRaises(
          LookupError, fromencodedobject, b, "ascii", "foo"
      )
      self.assertRaises(TypeError, fromencodedobject, "abc", NULL)
      self.assertRaises(TypeError, fromencodedobject, "abc", "ascii")
      self.assertRaises(TypeError, fromencodedobject, [], NULL)
      self.assertRaises(TypeError, fromencodedobject, [], "ascii")
      self.assertRaises(SystemError, fromencodedobject, NULL, NULL)
      self.assertRaises(SystemError, fromencodedobject, NULL, "ascii")
  
imports: import unittest
  import sys
  from test.support import import_helper
label_desc: Use image node_id 1 for calling the CAPITest obj's underlying member method code with example usage: obj.test_fromencodedobject() without return types