code: def test_expandvars_nonascii(self):
      expandvars = self.pathmodule.expandvars
  
      def check(value, expected):
          self.assertEqual(expandvars(value), expected)
  
      with os_helper.EnvironmentVarGuard() as env:
          env.clear()
          nonascii = os_helper.FS_NONASCII
          env["spam"] = nonascii
          env[nonascii] = "ham" + nonascii
          check(nonascii, nonascii)
          check("$spam bar", "%s bar" % nonascii)
          check("${spam}bar", "%sbar" % nonascii)
          check("${%s}bar" % nonascii, "ham%sbar" % nonascii)
          check("$bar%s bar" % nonascii, "$bar%s bar" % nonascii)
          check("$spam}bar", "%s}bar" % nonascii)
  
          check(os.fsencode(nonascii), os.fsencode(nonascii))
          check(b"$spam bar", os.fsencode("%s bar" % nonascii))
          check(b"${spam}bar", os.fsencode("%sbar" % nonascii))
          check(
              os.fsencode("${%s}bar" % nonascii),
              os.fsencode("ham%sbar" % nonascii),
          )
          check(
              os.fsencode("$bar%s bar" % nonascii),
              os.fsencode("$bar%s bar" % nonascii),
          )
          check(b"$spam}bar", os.fsencode("%s}bar" % nonascii))
  
imports: import genericpath
  import os
  import sys
  import unittest
  import warnings
  from test.support import is_emscripten
  from test.support import os_helper
  from test.support import warnings_helper
  from test.support.script_helper import assert_python_ok
  from test.support.os_helper import FakePath
label_desc: Use image node_id 4 for calling the CommonTest obj's underlying member method code with example usage: obj.test_expandvars_nonascii() without return types