Rev 5571: Demonstrate that test._captureVar() is dangerous. in file:///home/vila/src/bzr/bugs/690563-better-env-isolation/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Wed Dec 15 17:22:48 GMT 2010
At file:///home/vila/src/bzr/bugs/690563-better-env-isolation/
------------------------------------------------------------
revno: 5571
revision-id: v.ladeuil+lp at free.fr-20101215172248-25zppfv1n5k0dq4w
parent: pqm at pqm.ubuntu.com-20101215012832-s7gz2rnm1n94f4eu
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 690563-better-env-isolation
timestamp: Wed 2010-12-15 18:22:48 +0100
message:
Demonstrate that test._captureVar() is dangerous.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py 2010-11-19 23:03:19 +0000
+++ b/bzrlib/tests/test_selftest.py 2010-12-15 17:22:48 +0000
@@ -3411,3 +3411,21 @@
self.verbosity)
tests.run_suite(suite, runner_class=MyRunner, stream=StringIO())
self.assertLength(1, calls)
+
+
+class TestEnvironHandling(tests.TestCase):
+
+ def test__captureVar_None_called_twice_leaks(self):
+ self._captureVar('MYVAR', '42')
+ class Test(tests.TestCase):
+ def test_me(self):
+ # The first call records 42
+ self._captureVar('MYVAR', None)
+ self.assertEquals('42', self._old_env.get('MYVAR'))
+ # But the second one erases it !
+ self._captureVar('MYVAR', None)
+ self.assertEquals(None, self._old_env.get('MYVAR'))
+ result = tests.ExtendedTestResult(StringIO(), 0, 1)
+ Test('test_me').run(result)
+ # And we have lost all trace of the original value
+ self.assertEquals(None, self._old_env.get('MYVAR'))
More information about the bazaar-commits
mailing list