~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/__init__.py

  • Committer: Martin Pool
  • Date: 2005-08-30 03:10:32 UTC
  • Revision ID: mbp@sourcefrog.net-20050830031032-92ae5f0abb866ab8
- remove dead code and remove some small errors (pychecker)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import tempfile
21
21
import os
22
22
import sys
 
23
import subprocess
23
24
 
24
25
from testsweet import run_suite
25
26
import bzrlib.commands
228
229
        If a single string is based, it is split into words.
229
230
        For commands that are not simple space-separated words, please
230
231
        pass a list instead."""
231
 
        try:
232
 
            import shutil
233
 
            from subprocess import call
234
 
        except ImportError, e:
235
 
            _need_subprocess()
236
 
            raise
237
232
        cmd = self._formcmd(cmd)
238
233
        self.log('$ ' + ' '.join(cmd))
239
 
        actual_retcode = call(cmd, stdout=self._log_file, stderr=self._log_file)
 
234
        actual_retcode = subprocess.call(cmd, stdout=self._log_file,
 
235
                                         stderr=self._log_file)
240
236
        if retcode != actual_retcode:
241
237
            raise CommandFailed("test failed: %r returned %d, expected %d"
242
238
                                % (cmd, actual_retcode, retcode))
243
239
 
244
240
    def backtick(self, cmd, retcode=0):
245
241
        """Run a command and return its output"""
246
 
        try:
247
 
            import shutil
248
 
            from subprocess import Popen, PIPE
249
 
        except ImportError, e:
250
 
            _need_subprocess()
251
 
            raise
252
 
 
253
242
        cmd = self._formcmd(cmd)
254
 
        child = Popen(cmd, stdout=PIPE, stderr=self._log_file)
 
243
        child = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=self._log_file)
255
244
        outd, errd = child.communicate()
256
245
        self.log(outd)
257
246
        actual_retcode = child.wait()