def setUp(self):
args = sys.argv[1:]
self.verbose = '-v' in args
self.permanent_tempdir = '-p' in args
self.njobs = args[args.index('-n') + 1] if '-n' in args else None
if self.permanent_tempdir:
tempdir = os.path.join(tempfile.gettempdir(), 'yam_test')
if os.path.exists(tempdir) and '-d' in args:
shutil.rmtree(tempdir)
if not os.path.exists(tempdir):
os.mkdir(tempdir)
else:
tempdir = tempfile.mkdtemp(prefix='yam_test_')
self.cwd = os.getcwd()
os.chdir(tempdir)
self.tempdir = tempdir
# for coverage put .coveragerc config file into tempdir
# and append correct data_file parameter to config file
covfn = os.path.join(self.cwd, '.coverage')
if not os.path.exists('.coveragerc') and os.path.exists(covfn + 'rc'):
_replace_in_file(covfn + 'rc', '.coveragerc', '[run]',
'[run]\ndata_file = ' + covfn)
self.plotdir = os.path.join(self.tempdir, 'plots')
self.script = load_entry_point('yam', 'console_scripts', 'yam')
total = 74 - 2 * self.permanent_tempdir
self.pbar = tqdm.tqdm(total=total, desc='CLI tests passed')
评论列表
文章目录