code: def test_expandvars(self):
      expandvars = self.pathmodule.expandvars
      with os_helper.EnvironmentVarGuard() as env:
          env.clear()
          env["foo"] = "bar"
          env["{foo"] = "baz1"
          env["{foo}"] = "baz2"
          self.assertEqual(expandvars("foo"), "foo")
          self.assertEqual(expandvars("$foo bar"), "bar bar")
          self.assertEqual(expandvars("${foo}bar"), "barbar")
          self.assertEqual(expandvars("$[foo]bar"), "$[foo]bar")
          self.assertEqual(expandvars("$bar bar"), "$bar bar")
          self.assertEqual(expandvars("$?bar"), "$?bar")
          self.assertEqual(expandvars("$foo}bar"), "bar}bar")
          self.assertEqual(expandvars("${foo"), "${foo")
          self.assertEqual(expandvars("${{foo}}"), "baz1}")
          self.assertEqual(expandvars("$foo$foo"), "barbar")
          self.assertEqual(expandvars("$bar$bar"), "$bar$bar")
  
          self.assertEqual(expandvars(b"foo"), b"foo")
          self.assertEqual(expandvars(b"$foo bar"), b"bar bar")
          self.assertEqual(expandvars(b"${foo}bar"), b"barbar")
          self.assertEqual(expandvars(b"$[foo]bar"), b"$[foo]bar")
          self.assertEqual(expandvars(b"$bar bar"), b"$bar bar")
          self.assertEqual(expandvars(b"$?bar"), b"$?bar")
          self.assertEqual(expandvars(b"$foo}bar"), b"bar}bar")
          self.assertEqual(expandvars(b"${foo"), b"${foo")
          self.assertEqual(expandvars(b"${{foo}}"), b"baz1}")
          self.assertEqual(expandvars(b"$foo$foo"), b"barbar")
          self.assertEqual(expandvars(b"$bar$bar"), b"$bar$bar")
  
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 3 for calling the CommonTest obj's underlying member method code with example usage: obj.test_expandvars() without return types