Rev 5577: For test_import_tariff we want to preserve the env vars *before* isolation. in file:///home/vila/src/bzr/bugs/690563-better-env-isolation/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Thu Dec 16 12:12:16 GMT 2010
At file:///home/vila/src/bzr/bugs/690563-better-env-isolation/
------------------------------------------------------------
revno: 5577
revision-id: v.ladeuil+lp at free.fr-20101216121216-04t1b8lre2keqb3w
parent: v.ladeuil+lp at free.fr-20101216113114-bykxo3hss4dcawgf
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 690563-better-env-isolation
timestamp: Thu 2010-12-16 13:12:16 +0100
message:
For test_import_tariff we want to preserve the env vars *before* isolation.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_import_tariff.py'
--- a/bzrlib/tests/test_import_tariff.py 2010-10-20 11:16:16 +0000
+++ b/bzrlib/tests/test_import_tariff.py 2010-12-16 12:12:16 +0000
@@ -17,6 +17,7 @@
"""Tests for how many modules are loaded in executing various commands."""
+import os
from testtools import content
from bzrlib.plugin import (
@@ -29,12 +30,19 @@
class TestImportTariffs(TestCaseWithTransport):
-
"""Check how many modules are loaded for some representative scenarios.
See the Testing Guide in the developer documentation for more explanation.
"""
+ def setUp(self):
+ # Preserve some env vars as we want to escape the isolation for them
+ self.preserved_env_vars = {}
+ for name in ('BZR_HOME', 'BZR_PLUGIN_PATH', 'BZR_DISABLE_PLUGINS',
+ 'BZR_PLUGINS_AT', 'HOME'):
+ self.preserved_env_vars[name] = os.environ.get(name)
+ super(TestImportTariffs, self).setUp()
+
def run_command_check_imports(self, args, forbidden_imports):
"""Run bzr ARGS in a subprocess and check its imports.
@@ -50,15 +58,11 @@
# more likely to always show everything. And we use the environment
# variable rather than 'python -v' in the hope it will work even if
# bzr is frozen and python is not explicitly specified. -- mbp 20100208
- #
+
# Normally we want test isolation from the real $HOME but here we
# explicitly do want to test against things installed there, therefore
# we pass it through.
- env_changes = dict(PYTHONVERBOSE='1')
- for name in ['BZR_HOME', 'BZR_PLUGIN_PATH',
- 'BZR_DISABLE_PLUGINS', 'BZR_PLUGINS_AT',
- 'HOME',]:
- env_changes[name] = self._old_env.get(name)
+ env_changes = dict(PYTHONVERBOSE='1', **self.preserved_env_vars)
out, err = self.run_bzr_subprocess(args,
allow_plugins=(not are_plugins_disabled()),
env_changes=env_changes)
More information about the bazaar-commits
mailing list