def setup(self): if not TaskWarriorShellout.can_use(): # Sometimes the 'task' command line tool is not installed. raise nose.SkipTest("taskwarrior not installed") # Create some temporary config stuff fd, fname = tempfile.mkstemp(prefix='taskw-testsrc') dname = tempfile.mkdtemp(prefix='taskw-tests-data') with open(fname, 'w') as f: f.writelines([ 'data.location=%s\n' % dname, 'uda.somestring.label=Testing String\n', 'uda.somestring.type=string\n', 'uda.somedate.label=Testing Date\n', 'uda.somedate.type=date\n', 'uda.somenumber.label=Testing Number\n', 'uda.somenumber.type=numeric\n', ]) # Create empty .data files for piece in ['completed', 'pending', 'undo']: with open(os.path.sep.join([dname, piece + '.data']), 'w'): pass # Save names for .tearDown() self.fname, self.dname = fname, dname # Create the taskwarrior db object that each test will use. self.tw = TaskWarriorShellout(config_filename=fname, marshal=True)
def should_skip(self): """ If 'task' is not installed, we can't run these tests. """ return not TaskWarriorShellout.can_use()