/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_import_tariff.py

merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
            self.preserved_env_vars[name] = os.environ.get(name)
63
63
        super(TestImportTariffs, self).setUp()
64
64
 
65
 
    def start_bzr_subprocess_with_import_check(self, args):
 
65
    def start_bzr_subprocess_with_import_check(self, args, stderr_file=None):
66
66
        """Run a bzr process and capture the imports.
67
67
 
68
68
        This is fairly expensive because we start a subprocess, so we aim to
79
79
        # explicitly do want to test against things installed there, therefore
80
80
        # we pass it through.
81
81
        env_changes = dict(PYTHONVERBOSE='1', **self.preserved_env_vars)
82
 
        return self.start_bzr_subprocess(args, env_changes=env_changes,
83
 
            allow_plugins=(not are_plugins_disabled()))
 
82
        kwargs = dict(env_changes=env_changes,
 
83
                      allow_plugins=(not are_plugins_disabled()))
 
84
        if stderr_file:
 
85
            # We don't want to update the whole call chain so we insert stderr
 
86
            # *iff* we need to
 
87
            kwargs['stderr'] = stderr_file
 
88
        return self.start_bzr_subprocess(args, **kwargs)
84
89
 
85
90
    def check_forbidden_modules(self, err, forbidden_imports):
86
91
        """Check for forbidden modules in stderr.
187
192
    def test_simple_serve(self):
188
193
        # 'serve' in a default format working tree shouldn't need many modules
189
194
        tree = self.make_branch_and_tree('.')
 
195
        # Capture the bzr serve process' stderr in a file to avoid deadlocks
 
196
        # while the smart client interacts with it.
 
197
        stderr_file = open('bzr-serve.stderr', 'w')
190
198
        process = self.start_bzr_subprocess_with_import_check(['serve',
191
 
            '--inet', '-d', tree.basedir])
 
199
            '--inet', '-d', tree.basedir], stderr_file=stderr_file)
192
200
        url = 'bzr://localhost/'
193
201
        self.permit_url(url)
194
202
        client_medium = medium.SmartSimplePipesClientMedium(
200
208
        process.stdin = None
201
209
        (out, err) = self.finish_bzr_subprocess(process,
202
210
            universal_newlines=False)
 
211
        stderr_file.close()
 
212
        with open('bzr-serve.stderr', 'r') as stderr_file:
 
213
            err = stderr_file.read()
203
214
        self.check_forbidden_modules(err,
204
215
            ['bzrlib.annotate',
205
216
            'bzrlib.atomicfile',