def out(self, cmd, text=None):
"""Test if text is in output of command"""
# for TRAVIS use maximal two cores
if (self.njobs and '--njobs' not in cmd and
cmd.split()[0] in ('correlate', 'stretch')):
cmd = cmd + ' --njobs ' + self.njobs
# disabling the logger is necessary, because the logging
# configuration cannot be changed easily on subsequent calls
# of yam in this test suite
if self.verbose and cmd.split()[0] in ('correlate', 'stack', 'stretch'):
if '-v' not in cmd:
cmd = cmd + ' -vvv'
logging.getLogger('yam').disabled = False
elif self.verbose:
logging.getLogger('yam').disabled = True
if self.verbose:
tqdm.tqdm.write('> yam ' + cmd)
# catching all output, print only if tests are run with -v
try:
with io.StringIO() as f:
with redirect_stdout(f), redirect_stderr(f):
try:
self.script(cmd.split())
except SystemExit:
pass
output = f.getvalue()
if self.verbose:
tqdm.tqdm.write(output)
finally:
self.pbar.update(1)
if text is not None:
self.assertIn(text, output)
return output
评论列表
文章目录