code: def test_device_encoding(self):
      # Use stdout as TTY
      if not sys.stdout.isatty():
          self.skipTest("sys.stdout is not a TTY")
  
      filename = "out.txt"
      self.addCleanup(os_helper.unlink, filename)
  
      code = (
          f"import os, sys; fd = sys.stdout.fileno(); "
          f'out = open({filename!r}, "w", encoding="utf-8"); '
          f"print(os.isatty(fd), os.device_encoding(fd), file=out); "
          f"out.close()"
      )
      cmd = [sys.executable, "-X", "utf8", "-c", code]
      # The stdout TTY is inherited to the child process
      proc = subprocess.run(cmd, text=True)
      self.assertEqual(proc.returncode, 0, proc)
  
      # In UTF-8 Mode, device_encoding(fd) returns "UTF-8" if fd is a TTY
      with open(filename, encoding="utf8") as fp:
          out = fp.read().rstrip()
      self.assertEqual(out, "True utf-8")
  
imports: import locale
  import subprocess
  import sys
  import textwrap
  import unittest
  from test import support
  from test.support.script_helper import assert_python_ok, assert_python_failure
  from test.support import os_helper, MS_WINDOWS
label_desc: Use image node_id 16 for calling the UTF8ModeTests obj's underlying member method code with example usage: obj.test_device_encoding() without return types