diff options
Diffstat (limited to 'Lib/test/test_tcl.py')
| -rw-r--r-- | Lib/test/test_tcl.py | 25 | 
1 files changed, 11 insertions, 14 deletions
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py index 0b05c54..5d16968 100644 --- a/Lib/test/test_tcl.py +++ b/Lib/test/test_tcl.py @@ -144,23 +144,20 @@ class TclTest(unittest.TestCase):          import sys          if sys.platform.startswith(('win', 'darwin', 'cygwin')):              return  # no failure possible on windows? -        if 'DISPLAY' in os.environ: -            old_display = os.environ['DISPLAY'] -            del os.environ['DISPLAY'] -            # on some platforms, deleting environment variables -            # doesn't actually carry through to the process level -            # because they don't support unsetenv -            # If that's the case, abort. -            display = os.popen('echo $DISPLAY').read().strip() -            if display: -                return -        try: +        with test_support.EnvironmentVarGuard() as env: +            if 'DISPLAY' in os.environ: +                del env['DISPLAY'] +                # on some platforms, deleting environment variables +                # doesn't actually carry through to the process level +                # because they don't support unsetenv +                # If that's the case, abort. +                display = os.popen('echo $DISPLAY').read().strip() +                if display: +                    return +              tcl = Tcl()              self.assertRaises(TclError, tcl.winfo_geometry)              self.assertRaises(TclError, tcl.loadtk) -        finally: -            if old_display is not None: -                os.environ['DISPLAY'] = old_display  def test_main():      test_support.run_unittest(TclTest, TkinterTest)  | 
