def testWithBrokenFile(self): file = self.folder.file('index.db') file.write('this is not a database file...\n') self.assertTrue(file.exists()) with tests.LoggingFilter('zim.notebook.index', 'Overwriting'): with tests.LoggingFilter('zim.notebook.index', 'Could not access'): index = Index(file.path, self.layout) self.assertTrue(file.exists()) self.assertEqual(index.get_property('db_version'), DB_VERSION)
def testWithLockedFile(self): file = self.folder.file('index.db') file.write('this is not a database file...\n') os.chmod(file.path, 0o000) # make read-only self.addCleanup(lambda: os.chmod(file.path, 0o700)) self.assertTrue(file.exists()) with tests.LoggingFilter('zim.notebook.index', 'Overwriting'): with tests.LoggingFilter('zim.notebook.index', 'Could not access'): index = Index(file.path, self.layout) self.assertTrue(file.exists()) self.assertEqual(index.get_property('db_version'), DB_VERSION)
def runTest(self): output_folder = self.setUpFolder() notebook = self.setUpNotebook(content=tests.FULL_NOTEBOOK) i = 0 print('') for template, file in list_templates(self.format): #print 'Testing template: %s' % template pages = AllPages(notebook) # TODO - sub-section ? exporter = build_notebook_exporter(output_folder.folder(template), self.format, template) self.assertIsInstance(exporter, MultiFileExporter) with tests.LoggingFilter('zim.formats.latex', 'Could not find latex equation'): exporter.export(pages) file = exporter.layout.page_file(Path('roundtrip')) text = file.read() self.assertIn('Lorem ipsum dolor sit amet', text) i += 1 if self.format in ('html', 'latex'): self.assertTrue(i >= 3) # Ensure we actually tested something ..
def movePage(self, pre, move, post): notebook = self.setUpNotebook(content=pre[0]) self.assertEqual(self.getNotebookLinks(notebook), set(pre[1])) with tests.LoggingFilter('zim.notebook', message='Number of links after move'): notebook.move_page(Path(move[0]), Path(move[1])) self.assertEqual(self.getNotebookContent(notebook), post[0]) self.assertEqual(self.getNotebookLinks(notebook), set(post[1]))
def runTest(self): ## Without argument should prompt def testAddNotebookDialog(dialog): self.assertIn(dialog.__class__.__name__, ('AddNotebookDialog', 'NotebookDialog') ) cmd = GuiCommand('gui') with tests.DialogContext(testAddNotebookDialog): cmd.run() # Exist without running due to no notebook given in dialog ### Try again with argument dir = self.create_tmp_dir() cmd = GuiCommand('gui') cmd.parse_options(dir) with tests.LoggingFilter('zim', 'Exception while loading plugin:'): window = cmd.run() self.addCleanup(window.destroy) self.assertEqual(window.__class__.__name__, 'MainWindow') self.assertEqual(window.ui.notebook.uri, Dir(dir).uri) # XXX window2 = cmd.run() self.assertIs(window2, window)
def runTest(self): dir = Dir(self.create_tmp_dir()) #~ dir = VirtualDir('/test') i = 0 print '' for template, file in list_templates(self.format): print 'Testing template: %s' % template notebook = tests.new_notebook(fakedir='/foo') pages = AllPages(notebook) # TODO - sub-section ? exporter = build_notebook_exporter(dir.subdir(template), self.format, template) self.assertIsInstance(exporter, MultiFileExporter) with tests.LoggingFilter('zim.formats.latex', 'Could not find latex equation'): exporter.export(pages) file = exporter.layout.page_file(Path('roundtrip')) text = file.read() self.assertIn('Lorem ipsum dolor sit amet', text) i += 1 if self.format in ('html', 'latex'): self.assertTrue(i >= 3)
def _testDragAndDropCallbacks(self, workaround): treeview = self.treeview mocktarget = tests.MockObject( return_values={'name': PAGELIST_TARGET_NAME}) mockselectiondata = tests.MockObject(return_values={ 'get_target': mocktarget, 'set': None }) treeview.do_drag_data_get(None, mockselectiondata, None, None) self.assertEqual(mockselectiondata.lastMethodCall, ('set', mocktarget, 8, b'testnotebook?Test\r\n')) if workaround: self.assertEqual(zim.gui.clipboard._internal_selection_data, b'testnotebook?Test\r\n') mockselectiondata.addMockMethod('get_data', None) else: zim.gui.clipboard._internal_selection_data = None mockselectiondata.addMockMethod('get_data', b'testnotebook?Test\r\n') treepath = treeview.get_model().find(Path('Foo')) position = Gtk.TreeViewDropPosition.INTO_OR_BEFORE treeview.get_dest_row_at_pos = lambda x, y: (treepath, position ) # MOCK method with tests.LoggingFilter('zim.notebook', message='Number of links after move'): context = tests.MockObject(methods=('finish', )) treeview.do_drag_data_received(context, None, None, mockselectiondata, None, None)
def testExceptionHandlerWithGtk(self): def error_dialog_with_trace(dialog): self.assertIsInstance(dialog, ErrorDialog) self.assertTrue(dialog.showing_trace) def error_dialog_without_trace(dialog): self.assertIsInstance(dialog, ErrorDialog) self.assertFalse(dialog.showing_trace) zim.errors.set_use_gtk(True) try: self.assertTrue(zim.errors.use_gtk_errordialog) with tests.DialogContext( error_dialog_with_trace, error_dialog_with_trace, error_dialog_without_trace, error_dialog_without_trace, ): with tests.LoggingFilter(logger='zim.gui', message='Running ErrorDialog'): self.testExceptionHandler() except: zim.errors.set_use_gtk(False) raise else: zim.errors.set_use_gtk(False) self.assertFalse(zim.errors.use_gtk_errordialog)
def testNavigationCancel(self): notebook = self.setUpNotebook(content={'test': 'test123\n'}) mainwindow = setUpMainWindow(notebook, path='Test') def raise_error(page): raise AssertionError notebook.store_page = raise_error mainwindow.pageview.textview.get_buffer().set_text('Changed!') def cancel(dialog): self.assertIsInstance(dialog, SavePageErrorDialog) self.assertTrue(mainwindow.page.modified) self.assertEqual(mainwindow.page.dump('wiki'), ['Changed!\n']) dialog.response(Gtk.ResponseType.CANCEL) self.assertTrue(mainwindow.page.modified) self.assertEqual(mainwindow.page.dump('wiki'), ['Changed!\n']) self.assertEqual(mainwindow.page.name, 'Test') with tests.LoggingFilter('zim'): with tests.DialogContext(cancel): mainwindow.open_page(Path('Other page')) self.assertEqual(mainwindow.page.name, 'Test')
def runTest(self): from zim.gui.mainwindow import MainWindow ## Without argument should prompt def testAddNotebookDialog(dialog): self.assertIn(dialog.__class__.__name__, ('AddNotebookDialog', 'NotebookDialog')) cmd = GuiCommand('gui') with tests.DialogContext(testAddNotebookDialog): cmd.run( ) # Exits without running due to no notebook given in dialog ### Try again with argument dir = self.create_tmp_dir() cmd = GuiCommand('gui') cmd.parse_options(dir) with tests.WindowContext(MainWindow): with tests.LoggingFilter('zim', 'Exception while loading plugin:'): window = cmd.run() self.addCleanup(window.destroy) self.assertEqual(window.__class__.__name__, 'MainWindow') self.assertEqual(window.notebook.uri, Dir(dir).uri) # XXX self.assertGreaterEqual( len(ConfigManager.preferences['General']['plugins']), 3) self.assertGreaterEqual(len(window.pageview.__zim_extension_objects__), 3) with tests.WindowContext(MainWindow): window2 = cmd.run() self.assertIs(window2, window)
def testRobustness(self): '''Test history can deal with garbage data''' uistate = INIConfigFile(VirtualFile([])) uistate['History'].input({ 'list': 'FOOOO', 'recent': [["BARRRR", 0]], 'cursor': 'Not an integer', }) with tests.LoggingFilter(logger='zim.config', message='Invalid config'): with tests.LoggingFilter(logger='zim.history', message='Could not parse'): history = History(self.notebook, uistate) self.assertEqual(list(history.get_history()), []) self.assertEqual(list(history.get_recent()), []) self.assertIsNone(history.get_current())
def testIncludeFromParentDirNotAllowed(self): # test 'INCLUDE path' does not allow include from ../../ something self.file.write('[% foo="Test" %][% INCLUDE "../passwd.txt" %]') templ = Template(self.file) output = [] with tests.LoggingFilter('zim'): templ.process(output, {}) self.assertNotIn('FAIL', output)
def testOpenDocumentRootNotDefined(self): from zim.gui.widgets import ErrorDialog self.assertIsNone(self.notebook.document_root) with tests.LoggingFilter('zim', 'No document root defined'): with tests.ApplicationContext(): with tests.DialogContext(ErrorDialog): self.uiactions.open_document_root()
def runTest(self): from zim.gui.mainwindow import MainWindow cmd = ManualCommand('manual') with tests.WindowContext(MainWindow): with tests.LoggingFilter('zim', 'Exception while loading plugin:'): window = cmd.run() self.addCleanup(window.destroy) self.assertEqual(window.__class__.__name__, 'MainWindow')
def testOpenHelp(self, page=None): from zim.main import ZIM_APPLICATION ZIM_APPLICATION._running = True # HACK def check_window(window): self.assertEqual(window.notebook.folder.basename, 'manual') if page: self.assertEqual(window.page, page) with tests.LoggingFilter('zim', 'Exception while loading plugin:'): with tests.WindowContext(check_window, check_window): # window.present() called twice self.uiactions.show_help()
def testDiscard(self): def discard(dialog): self.assertIsInstance(dialog, SavePageErrorDialog) self.assertTrue(self.page.modified) self.assertEqual(self.page.dump('wiki'), ['Editing ...\n']) dialog.discard() self.assertFalse(self.page.modified) self.assertNotEqual(self.page.dump('wiki'), ['Editing ...\n']) with tests.LoggingFilter('zim'): with tests.DialogContext(discard): self.handler.save_page_now()
def testCancel(self): def cancel(dialog): self.assertIsInstance(dialog, SavePageErrorDialog) self.assertTrue(self.page.modified) self.assertEqual(self.page.dump('wiki'), ['Editing ...\n']) dialog.response(Gtk.ResponseType.CANCEL) self.assertTrue(self.page.modified) self.assertEqual(self.page.dump('wiki'), ['Editing ...\n']) with tests.LoggingFilter('zim'): with tests.DialogContext(cancel): self.handler.save_page_now()
def runTest(self): dir = Dir(self.create_tmp_dir()) file = dir.file('test.tex') page = Path('roundtrip') exporter = build_page_exporter(file, 'latex', 'Article', page) notebook = self.setUpNotebook(content=tests.FULL_NOTEBOOK) selection = SinglePage(notebook, page) with tests.LoggingFilter('zim.formats.latex', 'Could not find latex equation'): exporter.export(selection) result = file.read() #~ print result self.assertIn('\section{Head1}', result) # this implies that document_type "article" was indeed used
def runTest(self): folder = self.setUpFolder() layout = FilesLayout(folder) db = sqlite3.connect(':memory:') db.row_factory = sqlite3.Row file_indexer = tests.MockObject() indexer = PagesIndexer(db, layout, file_indexer) id1 = indexer.insert_page(Path('Test'), None) with tests.LoggingFilter('zim.notebook.index', 'Error while inserting page'): id2 = indexer.insert_page(Path('Test'), None) self.assertEqual(id1, id2)
def testLabelledCheckboxes(self): mydate = '%04i-%02i-%02i' % parse_date('11/12') wanted = [ (t('TODO: test heading with label'), []), (t('A'), []), (t('B'), []), (t('C'), []), (t('FIXME: dus'), []), # this time does not inherit due-date from non-task: (t('TODO: BAR !!!', prio=3), []), (t('Some more tasks !!!', prio=3, tags='home'), [ (t('Foo !', prio=1, tags='home'), []), (t('Bar', prio=3, tags='home'), []), ]), (t('TODO: dus'), []), (t('FIXME: jaja - TODO !! @FIXME', prio=2, tags='FIXME'), []), (t('TODO: dus - list item'), []), (t('FIXME: jaja - TODO !! @FIXME - list item', prio=2, tags='FIXME'), []), (t('A', tags='someday'), []), (t('B', tags='someday'), [ (t('B-1', tags='someday'), []), ]), (t('C', tags='someday'), []), (t('main task', tags='home'), [ (t('do this', open=False, tags='home'), []), (t('Next: do that', tags='home'), []), (t('Next: do something else', tags='home'), []), ]), ] tree = WikiParser().parse(WIKI_TEXT) tb = TokenBuilder() tree.visit(tb) tokens = tb.tokens testTokenStream(tokens) parser = TaskParser(all_checkboxes=False) with tests.LoggingFilter('zim.plugins.tasklist', 'Invalid date format'): tasks = parser.parse(tokens) #~ import pprint; pprint.pprint(tasks) self.assertEqual(tasks, wanted)
def testQueue(self): queue = ThumbnailQueue() self.assertTrue(queue.queue_empty()) # Test input / output src_file = self.setUpFolder(mock=tests.MOCK_ALWAYS_REAL).file('test.txt') src_file.write('Test 123\n') queue.queue_thumbnail_request(src_file, 64) # put an error in the queue dir = tests.ZIM_DATA_FOLDER.folder('pixmaps') pixmaps = set() for basename in dir.list_names(): if not basename.endswith('.svg'): file = dir.file(basename) pixmaps.add(file.path) queue.queue_thumbnail_request(file, 64) self.assertFalse(queue.queue_empty()) with tests.LoggingFilter('zim.plugins.attachmentbrowser', 'Exception'): queue.start() seen = set() i = len(pixmaps) while i > 0: i -= 1 file, size, thumbfile, pixbuf, mtime = queue.get_ready_thumbnail(block=True) seen.add(file.path) self.assertEqual(size, 64) self.assertTrue(thumbfile.exists()) self.assertIsInstance(pixbuf, GdkPixbuf.Pixbuf) self.assertEqual(mtime, file.mtime()) self.assertEqual(seen, pixmaps) # Test clear self.assertTrue(queue.queue_empty()) for path in pixmaps: file = LocalFile(path) queue.queue_thumbnail_request(file, 64) self.assertFalse(queue.queue_empty()) queue.start() time.sleep(0.1) queue.clear_queue() self.assertTrue(queue.queue_empty())
def testQueue(self): queue = ThumbnailQueue() self.assertTrue(queue.queue_empty()) # Test input / output queue.queue_thumbnail_request(self.SRC_DIR.file('README.txt'), 64) # put an error in the queue dir = self.SRC_DIR.folder('data/pixmaps') pixmaps = set() for basename in dir.list_names(): if not basename.endswith('.svg'): file = dir.file(basename) pixmaps.add(file) queue.queue_thumbnail_request(file, 64) self.assertFalse(queue.queue_empty()) with tests.LoggingFilter('zim.plugins.attachmentbrowser', 'Exception'): queue.start() seen = set() i = len(pixmaps) while i > 0: i -= 1 file, size, thumbfile, pixbuf, mtime = queue.get_ready_thumbnail( block=True) seen.add(file) self.assertEqual(size, 64) self.assertTrue(thumbfile.exists()) self.assertIsInstance(pixbuf, gtk.gdk.Pixbuf) self.assertEqual(mtime, file.mtime()) self.assertEqual(seen, pixmaps) # Test clear self.assertTrue(queue.queue_empty()) for file in pixmaps: queue.queue_thumbnail_request(file, 64) self.assertFalse(queue.queue_empty()) queue.start() time.sleep(0.1) queue.clear_queue() self.assertTrue(queue.queue_empty())
def runTest(self, adapterclass): with tests.LoggingFilter(logger='zim.plugins.spell'): # Hide exceptions window = setUpMainWindow(self.setUpNotebook(content=('Test', 'Foo', 'Bar'))) plugin = PluginManager.load_plugin('spell') ext = find_extension(window.pageview, zim.plugins.spell.SpellPageViewExtension) self.assertIs(ext._adapter_cls, adapterclass) # ensure switching library worked ext.toggle_spellcheck() ext.toggle_spellcheck() ext.toggle_spellcheck() window.open_page(Path('Foo')) window.open_page(Path('Bar')) ext.toggle_spellcheck() window.open_page(Path('Foo')) window.open_page(Path('Bar'))
def testLogging(self): from zim.gui.exportdialog import LogContext mylogger = logging.getLogger('zim.export') foologger = logging.getLogger('zim.foo') log_context = LogContext() with tests.LoggingFilter(logger='zim', message='Test'): with log_context: mylogger.warn('Test export warning') mylogger.debug('Test export debug') foologger.warn('Test foo') file = log_context.file self.assertTrue(file.exists()) #~ print ">>>\n", file.read(), "\n<<<" self.assertTrue('Test export warning' in file.read()) self.assertFalse('Test export debug' in file.read()) self.assertFalse('Test foo' in file.read())
def testSaveCopy(self): folder = self.setUpFolder(mock=tests.MOCK_ALWAYS_REAL) file = folder.file('copy.txt') def save_copy(dialog): self.assertIsInstance(dialog, SavePageErrorDialog) self.assertTrue(self.page.modified) self.assertEqual(self.page.dump('wiki'), ['Editing ...\n']) dialog.save_copy() self.assertFalse(self.page.modified) self.assertNotEqual(self.page.dump('wiki'), ['Editing ...\n']) def save_copy_dialog(dialog): dialog.set_file(file) dialog.do_response_ok() with tests.LoggingFilter('zim'): with tests.DialogContext(save_copy, save_copy_dialog): self.handler.save_page_now() self.assertEqual(file.read(), 'Editing ...\n')
def testError(self): def creator_with_failure(*a): raise ThumbnailCreatorFailure def creator_with_error(*a): raise ValueError file = self.SRC_DIR.file('data/zim.png') self.assertTrue(file.exists()) self.assertTrue(file.isimage()) for creator in creator_with_failure, creator_with_error: #~ print(">>", creator.__name__) queue = ThumbnailQueue(creator) queue.queue_thumbnail_request(file, 64) with tests.LoggingFilter('zim.plugins.attachmentbrowser', 'Exception'): queue.start() while not queue.queue_empty(): r = queue.get_ready_thumbnail() self.assertIsNone(r[0], None)
def runTest(self, adapterclass): with tests.LoggingFilter( logger='zim.plugins.spell'): # Hide exceptions ui = setupGtkInterface(self) plugin = ui.plugins.load_plugin('spell') plugin.extend(ui.mainwindow) ext = plugin.get_extension(zim.plugins.spell.MainWindowExtension) self.assertIs(ext._adapter, adapterclass) # ensure switching library worked ext.toggle_spellcheck() ext.toggle_spellcheck() ext.toggle_spellcheck() ui.open_page(Path('Foo')) ui.open_page(Path('Bar')) ext.toggle_spellcheck() ui.open_page(Path('Foo')) ui.open_page(Path('Bar')) ext.toggle_spellcheck()
def runTest(self): manager = self.manager ## Test basic file file = manager.get_config_file('foo.conf') self.assertIsInstance(file, ConfigFile) self.assertEqual(file.read(), 'FOO!\n') newfile = manager.get_config_file('foo.conf') self.assertEqual(id(file), id(newfile)) ## Test basic dict dict = manager.get_config_dict('dict.conf') self.assertIsInstance(dict, INIConfigFile) dict['FOO'].setdefault('foo', 'xxx') self.assertEqual(dict['FOO']['foo'], 'test') newdict = manager.get_config_dict('dict.conf') self.assertEqual(id(dict), id(newdict)) dict['FOO'].setdefault('bar', 'yyy') dict['FOO'].setdefault('newkey', 'ja') dict['FOO']['foo'] = 'dus' text = manager.get_config_file('dict.conf').read() # We implicitly test that updates are stored already automatically self.assertEqual(text, '''\ [FOO] foo=dus bar=test123 newkey=ja ''') # Test backward compatibility with tests.LoggingFilter('zim.config', 'Use of "<profile>/"'): newdict = manager.get_config_dict('<profile>/dict.conf') self.assertEqual(id(dict), id(newdict))
def testAllCheckboxes(self): from zim.plugins.tasklist.indexer import TaskParser from zim.parsing import parse_date NO_DATE = '9999' def t(desc, open=True, start=0, due=NO_DATE, prio=0, tags=''): # Generate a task tuple # 0:open, 1:prio, 2:start, 3:due, 4:tags, 5:desc if tags: tags = set(str(tags).split(',')) else: tags = set() return [open, prio, start, due, tags, str(desc)] mydate = '%04i-%02i-%02i' % parse_date('11/12') wanted = [ (t('TODO: test heading with label'), []), (t('A'), []), (t('B'), []), (t('C'), []), (t('D'), []), (t('E'), []), (t('FIXME: dus'), []), (t('Simple'), []), (t('List'), []), (t('List with'), [ (t('Nested items'), []), (t('Some are done', open=False), []), (t('Done but with open child', open=True), [ (t('Others not', open=False), []), (t('FOOOOO'), []), ]), ]), (t('Bar'), []), (t('And then there are @tags', tags='tags'), []), (t('Next: And due dates'), []), (t('Date [d: 11/12]', due=mydate), []), ( t('Date [d: 11/12/2012]', due='2012-12-11'), [ (t('TODO: BAR !!!', prio=3, due='2012-12-11'), []), # due date is inherited ]), (t('Date <2012-03-27 >2012-03-01', due='2012-03-27', start='2012-03-01'), []), (t('Date < wk1213.3', due='2012-03-28'), []), (t('Date < wk1213.3! with punctuation', due='2012-03-28', prio=1), []), (t('Not a date < wk1213.8'), []), (t('Not a date < wk1213foooooo'), []), # this list inherits the @home tag - and inherits prio (t('Some more tasks !!!', prio=3, tags='home'), [ (t('Foo !', prio=1, tags='home'), []), (t('Bar', prio=3, tags='home'), []), ]), (t('TODO: dus'), []), (t('FIXME: jaja - TODO !! @FIXME', prio=2, tags='FIXME'), []), (t('TODO: dus - list item'), []), (t('FIXME: jaja - TODO !! @FIXME - list item', prio=2, tags='FIXME'), []), (t('Sub item bullets'), []), (t('Sub item numbered'), []), (t('Main @tag1 @tag2 !', prio=1, tags='tag1,tag2'), [ (t('Sub1', prio=1, open=False, tags='tag1,tag2'), []), (t('Sub2 @tag3 !!!!', prio=4, tags='tag1,tag2,tag3'), [ (t('Sub2-1', prio=4, open=False, tags='tag1,tag2,tag3'), []), (t('Sub2-2 @tag4', prio=4, open=False, tags='tag1,tag2,tag3,tag4'), []), (t('Sub2-3', prio=4, tags='tag1,tag2,tag3'), []), ]), (t('Sub3', prio=1, tags='tag1,tag2'), []), ]), (t('A', tags='someday'), []), (t('B', tags='someday'), [ (t('B-1', tags='someday'), []), ]), (t('C', tags='someday'), []), (t('main task', tags='home'), [ (t('do this', open=False, tags='home'), []), (t('Next: do that', tags='home'), []), (t('Next: do something else', tags='home'), []), ]), (t('Closed parent task', open=True), [ (t('With open child'), []), (t('Must be open as well to show up in list'), []), ]), (t('Closed parent task', open=False), [ (t('With closed children', open=False), []), (t('Should not', open=False), []), ]), ] tree = WikiParser().parse(WIKI_TEXT) tb = TokenBuilder() tree.visit(tb) tokens = tb.tokens testTokenStream(tokens) parser = TaskParser() with tests.LoggingFilter('zim.plugins.tasklist', 'Invalid date format'): tasks = parser.parse(tokens) #~ import pprint; pprint.pprint(tasks) self.assertEqual(tasks, wanted)
def testLabelledCheckboxes(self): from zim.plugins.tasklist.indexer import TaskParser from zim.parsing import parse_date NO_DATE = '9999' def t(desc, open=True, start=0, due=NO_DATE, prio=0, tags=''): # Generate a task tuple # 0:open, 1:prio, 2:start, 3:due, 4:tags, 5:desc if tags: tags = set(str(tags).split(',')) else: tags = set() return [open, prio, start, due, tags, str(desc)] mydate = '%04i-%02i-%02i' % parse_date('11/12') wanted = [ (t('TODO: test heading with label'), []), (t('A'), []), (t('B'), []), (t('C'), []), (t('FIXME: dus'), []), # this time does not inherit due-date from non-task: (t('TODO: BAR !!!', prio=3), []), (t('Some more tasks !!!', prio=3, tags='home'), [ (t('Foo !', prio=1, tags='home'), []), (t('Bar', prio=3, tags='home'), []), ]), (t('TODO: dus'), []), (t('FIXME: jaja - TODO !! @FIXME', prio=2, tags='FIXME'), []), (t('TODO: dus - list item'), []), (t('FIXME: jaja - TODO !! @FIXME - list item', prio=2, tags='FIXME'), []), (t('A', tags='someday'), []), (t('B', tags='someday'), [ (t('B-1', tags='someday'), []), ]), (t('C', tags='someday'), []), (t('main task', tags='home'), [ (t('do this', open=False, tags='home'), []), (t('Next: do that', tags='home'), []), (t('Next: do something else', tags='home'), []), ]), ] tree = WikiParser().parse(WIKI_TEXT) tb = TokenBuilder() tree.visit(tb) tokens = tb.tokens testTokenStream(tokens) parser = TaskParser(all_checkboxes=False) with tests.LoggingFilter('zim.plugins.tasklist', 'Invalid date format'): tasks = parser.parse(tokens) #~ import pprint; pprint.pprint(tasks) self.assertEqual(tasks, wanted)