Merge lp:~vila/bzr/final-cleanup into lp:bzr

Proposed by Vincent Ladeuil
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 5584
Proposed branch: lp:~vila/bzr/final-cleanup
Merge into: lp:bzr
Prerequisite: lp:~vila/bzr/321320-isolate-doc-tests
Diff against target: 69 lines (+4/-27)
3 files modified
bzrlib/tests/__init__.py (+0/-5)
bzrlib/tests/test_selftest.py (+0/-22)
doc/en/release-notes/bzr-2.3.txt (+4/-0)
To merge this branch: bzr merge lp:~vila/bzr/final-cleanup
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+44323@code.launchpad.net

Commit message

Get rid of TestCase._old_env and _captureVar

Description of the change

Get rid of TestCase._old_env and _captureVar as discussed with poolie in https://code.edge.launchpad.net/~vila/bzr/690563-better-env-isolation/+merge/43941

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

Well that was pretty easy! :)

review: Approve
Revision history for this message
Vincent Ladeuil (vila) wrote :

>>>>> Martin Pool <email address hidden> writes:

    > Review: Approve
    > Well that was pretty easy! :)

Hehe

--5627A18135F.1293007400/axe--

Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/__init__.py'
2--- bzrlib/tests/__init__.py 2011-01-07 11:17:11 +0000
3+++ bzrlib/tests/__init__.py 2011-01-07 11:17:11 +0000
4@@ -941,7 +941,6 @@
5 self.addDetail("log", content.Content(content.ContentType("text",
6 "plain", {"charset": "utf8"}),
7 lambda:[self._get_log(keep_log_file=True)]))
8- self._old_env = {}
9 self._cleanEnvironment()
10 self._silenceUI()
11 self._startLogFile()
12@@ -1647,10 +1646,6 @@
13 for name, value in isolated_environ.iteritems():
14 self.overrideEnv(name, value)
15
16- def _captureVar(self, name, newvalue):
17- """Set an environment variable, and reset it when finished."""
18- self._old_env[name] = osutils.set_or_unset_env(name, newvalue)
19-
20 def _restoreHooks(self):
21 for klass, (name, hooks) in self._preserved_hooks.items():
22 setattr(klass, name, hooks)
23
24=== modified file 'bzrlib/tests/test_selftest.py'
25--- bzrlib/tests/test_selftest.py 2011-01-07 11:17:11 +0000
26+++ bzrlib/tests/test_selftest.py 2011-01-07 11:17:11 +0000
27@@ -3413,28 +3413,6 @@
28
29 class TestEnvironHandling(tests.TestCase):
30
31- def test__captureVar_None_called_twice_leaks(self):
32- self.failIf('MYVAR' in os.environ)
33- self._captureVar('MYVAR', '42')
34- # We need an embedded test to observe the bug
35- class Test(tests.TestCase):
36- def test_me(self):
37- # The first call save the 42 value
38- self._captureVar('MYVAR', None)
39- self.assertEquals(None, os.environ.get('MYVAR'))
40- self.assertEquals('42', self._old_env.get('MYVAR'))
41- # But the second one erases it !
42- self._captureVar('MYVAR', None)
43- self.assertEquals(None, self._old_env.get('MYVAR'))
44- output = StringIO()
45- result = tests.TextTestResult(output, 0, 1)
46- Test('test_me').run(result)
47- if not result.wasStrictlySuccessful():
48- self.fail(output.getvalue())
49- # And we have lost all trace of the original value
50- self.assertEquals(None, os.environ.get('MYVAR'))
51- self.assertEquals(None, self._old_env.get('MYVAR'))
52-
53 def test_overrideEnv_None_called_twice_doesnt_leak(self):
54 self.failIf('MYVAR' in os.environ)
55 self.overrideEnv('MYVAR', '42')
56
57=== modified file 'doc/en/release-notes/bzr-2.3.txt'
58--- doc/en/release-notes/bzr-2.3.txt 2011-01-07 11:17:11 +0000
59+++ doc/en/release-notes/bzr-2.3.txt 2011-01-07 11:17:11 +0000
60@@ -103,6 +103,10 @@
61 * Check sphinx compatibility for tests requiring older sphinx versions.
62 (Vincent Ladeuil, #688072)
63
64+* ``TestCase._captureVar`` and ``TestCase._old_env`` have been deleted due to
65+ bug #690563. Test writers are encouraged to use ``TestCase.overrideEnv``
66+ instead. (Vincent Ladeuil)
67+
68 * ``TestDebuntuExpansions`` was escaping the test isolation by calling the
69 wrong base class ``setUp``. (Vincent Ladeuil, #684622)
70