~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to testsweet.py

  • Committer: Martin Pool
  • Date: 2005-08-26 02:37:12 UTC
  • Revision ID: mbp@sourcefrog.net-20050826023712-cf1f99871f0395f4
- make TestCase._formcommand private

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
        import time
75
75
        import os
76
76
        import tempfile
 
77
        import logging
 
78
        
77
79
        self.TEST_LOG = tempfile.NamedTemporaryFile(mode='wt', bufsize=0)
78
80
        # save stdout & stderr so there's no leakage from code-under-test
79
81
        self.real_stdout = sys.stdout
80
82
        self.real_stderr = sys.stderr
81
83
        sys.stdout = sys.stderr = self.TEST_LOG
 
84
        
 
85
        # set up default python log handler
 
86
        #self._handler = logging.StreamHandler(self.TEST_LOG)
 
87
        #self._handler.setLevel(logging.DEBUG)
 
88
        #logging.getLogger('').addHandler(self._handler)
 
89
        
82
90
        self.log("%s setup" % self.id())
83
91
 
84
92
    def tearDown(self):
 
93
        # logging.getLogger('').removeHandler(self._handler)
85
94
        sys.stdout = self.real_stdout
86
95
        sys.stderr = self.real_stderr
87
96
        self.log("%s teardown" % self.id())
171
180
        os.chdir(self._currentdir)
172
181
        super(FunctionalTestCase, self).tearDown()
173
182
 
174
 
    def formcmd(self, cmd):
 
183
    def _formcmd(self, cmd):
175
184
        if isinstance(cmd, basestring):
176
185
            cmd = cmd.split()
177
186
        if cmd[0] == 'bzr':
195
204
        except ImportError, e:
196
205
            _need_subprocess()
197
206
            raise
198
 
        cmd = self.formcmd(cmd)
 
207
        cmd = self._formcmd(cmd)
199
208
        self.log('$ ' + ' '.join(cmd))
200
209
        actual_retcode = call(cmd, stdout=self.TEST_LOG, stderr=self.TEST_LOG)
201
210
        if retcode != actual_retcode:
211
220
            _need_subprocess()
212
221
            raise
213
222
 
214
 
        cmd = self.formcmd(cmd)
 
223
        cmd = self._formcmd(cmd)
215
224
        child = Popen(cmd, stdout=PIPE, stderr=self.TEST_LOG)
216
225
        outd, errd = child.communicate()
217
226
        self.log(outd)