aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2009-05-01 19:58:58 +0000
committerWalter Dörwald <walter@livinglogic.de>2009-05-01 19:58:58 +0000
commit155374d95d8ecd235d3a3edd92dd6f6a23d59f11 (patch)
tree91deb4c1d292387d2b216d869e79311cad1dbc61 /Lib/test/test_tcl.py
parentIssue #5859: Remove '%f' to '%g' formatting switch for large floats. (diff)
downloadcpython-155374d95d8ecd235d3a3edd92dd6f6a23d59f11.tar.gz
cpython-155374d95d8ecd235d3a3edd92dd6f6a23d59f11.tar.bz2
cpython-155374d95d8ecd235d3a3edd92dd6f6a23d59f11.zip
Merged revisions 72167 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r72167 | walter.doerwald | 2009-05-01 19:35:37 +0200 (Fr, 01 Mai 2009) | 5 lines Make test.test_support.EnvironmentVarGuard behave like a dictionary. All changes are mirrored to the underlying os.environ dict, but rolled back on exit from the with block. ........
Diffstat (limited to 'Lib/test/test_tcl.py')
-rw-r--r--Lib/test/test_tcl.py25
1 files changed, 11 insertions, 14 deletions
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
index f0eb863594b..cfff971dbf2 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 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():
support.run_unittest(TclTest, TkinterTest)