def test_ls(self): """Tests :func:`hkshell.ls`.""" class MyOutput(): @staticmethod def write(str): output_list.append(str) self.init_hkshell() output = MyOutput() hkshell.options.output = output hklib.localtime_fun = time.gmtime # ls with default parameters output_list = [] hkshell.ls() self.assertEquals( output_list, ['<0> author0 (2008.08.20. 15:41)\n', ' <1> author1 (2008.08.20. 15:41)\n', ' <2> author2 (2008.08.20. 15:41)\n', ' <3> author3 (2008.08.20. 15:41)\n', '<4> author4 (2008.08.20. 15:41)\n']) # ls with given parameters hkshell.aTr(1,['mytag1','mytag2']) output_list = [] hkshell.ls(hkshell.ps([1,2,4]), show_author=False, show_tags=True, show_date=False, indent=4) self.assertEquals( output_list, [' <1> [mytag1,mytag2]\n', ' <2> [mytag1,mytag2]\n', '<4> []\n'])
def test_ls(self): """Tests :func:`hkshell.ls`.""" class MyOutput(): # Class has no __init__ method # pylint: disable=W0232 @staticmethod def write(str): output_list.append(str) self.init_hkshell() output = MyOutput() hkshell.options.output = output hklib.localtime_fun = time.gmtime # ls with default parameters output_list = [] hkshell.ls() self.assertEqual( output_list, ['<my_heap/0> subject0 author0 (2008.08.20. 15:41)\n', ' <my_heap/1> subject1 author1 (2008.08.20. 15:41)\n', ' <my_heap/2> subject2 author2 (2008.08.20. 15:41)\n', ' <my_heap/3> subject3 author3 (2008.08.20. 15:41)\n', '<my_other_heap/0> subject0 author0 (2008.08.20. 15:41)\n', '<my_heap/4> subject4 author4 (2008.08.20. 15:41)\n']) # ls with given parameters hkshell.aTr('my_heap/1', ['mytag1', 'mytag2']) output_list = [] hkshell.ls(hkshell.ps([1, 2, 4]), show_author=False, show_tags=True, show_date=False, indent=4) self.assertEqual( output_list, [' <my_heap/1> subject1 [mytag1,mytag2]\n', ' <my_heap/2> subject2 [mytag1,mytag2]\n', '<my_heap/4> subject4 []\n'])
def lsr(heapid): """Print a whole thread, ie. recursive ls.""" hkshell.ls(hkshell.ps(heapid).exp())