code: def test_env_var(self):
      code = "import sys; print(sys.flags.utf8_mode)"
  
      out = self.get_output("-c", code, PYTHONUTF8="1")
      self.assertEqual(out, "1")
  
      out = self.get_output("-c", code, PYTHONUTF8="0")
      self.assertEqual(out, "0")
  
      # -X utf8 has the priority over PYTHONUTF8
      out = self.get_output("-X", "utf8=0", "-c", code, PYTHONUTF8="1")
      self.assertEqual(out, "0")
  
      if MS_WINDOWS:
          # PYTHONLEGACYWINDOWSFSENCODING disables the UTF-8 mode
          # and has the priority over PYTHONUTF8
          out = self.get_output(
              "-X",
              "utf8",
              "-c",
              code,
              PYTHONUTF8="1",
              PYTHONLEGACYWINDOWSFSENCODING="1",
          )
          self.assertEqual(out, "0")
  
      # Cannot test with the POSIX locale, since the POSIX locale enables
      # the UTF-8 mode
      if not self.posix_locale():
          # PYTHONUTF8 should be ignored if -E is used
          out = self.get_output("-E", "-c", code, PYTHONUTF8="1")
          self.assertEqual(out, "0")
  
      # invalid mode
      out = self.get_output("-c", code, PYTHONUTF8="xxx", failure=True)
      self.assertIn(
          "invalid PYTHONUTF8 environment variable value", out.rstrip()
      )
  
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 5 for calling the UTF8ModeTests obj's underlying member method code with example usage: obj.test_env_var() without return types