[Python-checkins] r53232 - in python/trunk: Doc/lib/libtest.tex Lib/test/test_support.py Misc/NEWS
A.M. Kuchling
amk at amk.ca
Thu Jan 25 21:00:44 CET 2007
On Thu, Jan 04, 2007 at 01:23:50AM +0100, brett.cannon wrote:
> New Revision: 53232
>
> Modified:
> python/trunk/Doc/lib/libtest.tex
> python/trunk/Lib/test/test_support.py
> python/trunk/Misc/NEWS
> Log:
> Add EnvironmentVarGuard to test.test_support. Provides a context manager to
> temporarily set or unset environment variables.
> + def set(self, envvar, value):
> + if envvar not in self._environ:
> + self._unset.add(envvar)
> + else:
> + self._reset[envvar] = self._environ[envvar]
> + self._environ[envvar] = value
Note that this will forget the original value if .set() is called
multiple times for the same value of envvar; is that a problem?
The fix would be to do:
if envvar not in self._reset:
self._reset[envvar] = ...
--amk
More information about the Python-checkins
mailing list