Exemplo n.º 1
0
   def test_ancestors(self):
       todos = Todos("""a
tb
t\tc
t\t\td""")
       self.assertTodos(todos.yield_ancestors(), '')
       self.assertTodos(todos.subitems[0].yield_ancestors(), '')
       self.assertTodos(todos.subitems[0].subitems[0].yield_ancestors(), 'a\n')
       self.assertTodos(todos.subitems[0].subitems[0].subitems[0].yield_ancestors(), '\tb\na\n')
       self.assertTodos(todos.subitems[0].subitems[0].subitems[0].subitems[0].yield_ancestors(), '\t\tc\n\tb\na\n')
Exemplo n.º 2
0
   def test_yield_children(self):
       todos = Todos("""a
tb
t\tc
t\tc
t\tx
t\t\td""")
       self.assertTodos(todos.yield_children(), ('a'))
       self.assertTodos(todos.subitems[0].yield_children(), ('\tb'))
       self.assertTodos(todos.subitems[0].subitems[0].yield_children(), ('\t\tc\n\t\tc\n\t\tx'))
Exemplo n.º 3
0
    def test_parent(self):
        todos = Todos("""a
\tb
\t\tc
\t\t\td
""")
        self.assertTodos(todos.yield_parent(), '')
        self.assertTodos(todos.subitems[0].yield_parent(), '')
        self.assertTodos(todos.subitems[0].subitems[0].yield_parent(), 'a')
        self.assertTodos(todos.subitems[0].subitems[0].subitems[0].yield_parent(), '\tb')
        self.assertTodos(todos.subitems[0].subitems[0].subitems[0].subitems[0].yield_parent(), '\t\tc')
Exemplo n.º 4
0
   def test_yield_children(self):
       todos = Todos("""a
tb
t\tc
t\tc
t\tx
t\t\td""")
       self.assertTodos(todos.yield_children(), ('a'))
       self.assertTodos(todos.subitems[0].yield_children(), ('\tb'))
       self.assertTodos(todos.subitems[0].subitems[0].yield_children(),
                        ('\t\tc\n\t\tc\n\t\tx'))
Exemplo n.º 5
0
   def test_yield_siblings(self):
       todos = Todos("""a
tb
t\tc
t\tc
t\tx
td""")
       self.assertTodos(todos.yield_siblings(), '')
       self.assertTodos(todos.subitems[0].yield_siblings(), 'a')
       self.assertTodos(todos.subitems[0].subitems[0].yield_siblings(), '\tb\n\td')
       self.assertTodos(todos.subitems[0].subitems[0].subitems[0].yield_siblings(), '\t\tc\n\t\tc\n\t\tx')
Exemplo n.º 6
0
   def test_preceding_siblings(self):
       todos = Todos("""a
tb
t\tc
t\tc
t\tx
td""")
       self.assertTodos(todos.yield_preceding_siblings(), '')
       self.assertTodos(todos.subitems[0].yield_preceding_siblings(), '')
       self.assertTodos(todos.subitems[0].subitems[0].yield_preceding_siblings(), '')
       self.assertTodos(todos.subitems[0].subitems[0].subitems[0].yield_preceding_siblings(), '')
       self.assertTodos(todos.subitems[0].subitems[0].subitems[1].yield_preceding_siblings(), '\t\tc')
       self.assertTodos(todos.subitems[0].subitems[0].subitems[2].yield_preceding_siblings(), '\t\tc\n\t\tc')
Exemplo n.º 7
0
    def test_parent(self):
        todos = Todos("""a
\tb
\t\tc
\t\t\td
""")
        self.assertTodos(todos.yield_parent(), '')
        self.assertTodos(todos.subitems[0].yield_parent(), '')
        self.assertTodos(todos.subitems[0].subitems[0].yield_parent(), 'a')
        self.assertTodos(
            todos.subitems[0].subitems[0].subitems[0].yield_parent(), '\tb')
        self.assertTodos(
            todos.subitems[0].subitems[0].subitems[0].subitems[0].yield_parent(
            ), '\t\tc')
Exemplo n.º 8
0
   def test_following(self):
       todos = Todos("""a
tb
t\tc
t\tc
t\tx
td""")
       self.assertTodos(todos.yield_following(), 'a\n\tb\n\t\tc\n\t\tc\n\t\tx\n\td')
       self.assertTodos(todos.subitems[0].yield_following(), '\tb\n\t\tc\n\t\tc\n\t\tx\n\td')
       self.assertTodos(todos.subitems[0].subitems[0].yield_following(), '\t\tc\n\t\tc\n\t\tx\n\td')
       self.assertTodos(todos.subitems[0].subitems[0].subitems[0].yield_following(), '\t\tc\n\t\tx\n\td')
       self.assertTodos(todos.subitems[0].subitems[0].subitems[1].yield_following(), '\t\tx\n\td')
       self.assertTodos(todos.subitems[0].subitems[0].subitems[2].yield_following(), '\td')
       self.assertTodos(todos.subitems[0].subitems[1].yield_following(), '')
Exemplo n.º 9
0
   def test_yield_siblings(self):
       todos = Todos("""a
tb
t\tc
t\tc
t\tx
td""")
       self.assertTodos(todos.yield_siblings(), '')
       self.assertTodos(todos.subitems[0].yield_siblings(), 'a')
       self.assertTodos(todos.subitems[0].subitems[0].yield_siblings(),
                        '\tb\n\td')
       self.assertTodos(
           todos.subitems[0].subitems[0].subitems[0].yield_siblings(),
           '\t\tc\n\t\tc\n\t\tx')
Exemplo n.º 10
0
   def test_ancestors(self):
       todos = Todos("""a
tb
t\tc
t\t\td""")
       self.assertTodos(todos.yield_ancestors(), '')
       self.assertTodos(todos.subitems[0].yield_ancestors(), '')
       self.assertTodos(todos.subitems[0].subitems[0].yield_ancestors(),
                        'a\n')
       self.assertTodos(
           todos.subitems[0].subitems[0].subitems[0].yield_ancestors(),
           '\tb\na\n')
       self.assertTodos(
           todos.subitems[0].subitems[0].subitems[0].subitems[0].
           yield_ancestors(), '\t\tc\n\tb\na\n')
Exemplo n.º 11
0
   def test_yield_descendants(self):
       todos = Todos("""a
tb
t\tc
t\tc
t\tx
t\t\td""")
       self.assertTodos(todos.yield_descendants(), str(todos))
       self.assertTodos(todos.subitems[0].yield_descendants(), """\tb
t\tc
t\tc
t\tx
t\t\td""")
       self.assertTodos(todos.subitems[0].subitems[0].yield_descendants(), """\t\tc
t\tc
t\tx
t\t\td""")
Exemplo n.º 12
0
   def test_yield_descendants(self):
       todos = Todos("""a
tb
t\tc
t\tc
t\tx
t\t\td""")
       self.assertTodos(todos.yield_descendants(), str(todos))
       self.assertTodos(todos.subitems[0].yield_descendants(), """\tb
t\tc
t\tc
t\tx
t\t\td""")
       self.assertTodos(todos.subitems[0].subitems[0].yield_descendants(),
                        """\t\tc
t\tc
t\tx
t\t\td""")
Exemplo n.º 13
0
    def test_filter(self):
        todos = Todos("""a
\tr
\t\tq
\tw
\t\tr
\te
\t\te
""").filter(lambda i: 'r' in i.get_text())
        self.assertTodos(todos, 'a\n\tr\n\tw\n\t\tr')
Exemplo n.º 14
0
   def test_preceding_siblings(self):
       todos = Todos("""a
tb
t\tc
t\tc
t\tx
td""")
       self.assertTodos(todos.yield_preceding_siblings(), '')
       self.assertTodos(todos.subitems[0].yield_preceding_siblings(), '')
       self.assertTodos(
           todos.subitems[0].subitems[0].yield_preceding_siblings(), '')
       self.assertTodos(
           todos.subitems[0].subitems[0].subitems[0].yield_preceding_siblings(
           ), '')
       self.assertTodos(
           todos.subitems[0].subitems[0].subitems[1].yield_preceding_siblings(
           ), '\t\tc')
       self.assertTodos(
           todos.subitems[0].subitems[0].subitems[2].yield_preceding_siblings(
           ), '\t\tc\n\t\tc')
Exemplo n.º 15
0
    def test_038b(self):
        items = list(
            Todos("""todo:
\tp
to:
\tto
\tto
\tko:
""").search('project *'))
        self.assertEqual([i.get_text() for i in items],
                         ['todo:', 'to:', '\tko:'])
Exemplo n.º 16
0
   def test_1(self):
       todos = Todos("""a:
tb
t\tc""")
       self.assertFalse(Todoitem('b') in todos)
       self.assertTrue(todos.subitems[0] in todos)
       self.assertTrue(todos.subitems[0].todoitem in todos)
       self.assertTrue(todos.subitems[0].subitems[0] in todos)
       self.assertTrue(todos.subitems[0].subitems[0].todoitem in todos)
       self.assertTrue(todos.subitems[0].subitems[0].subitems[0] in todos)
       self.assertTrue(
           todos.subitems[0].subitems[0].subitems[0].todoitem in todos)
Exemplo n.º 17
0
   def test_following(self):
       todos = Todos("""a
tb
t\tc
t\tc
t\tx
td""")
       self.assertTodos(todos.yield_following(),
                        'a\n\tb\n\t\tc\n\t\tc\n\t\tx\n\td')
       self.assertTodos(todos.subitems[0].yield_following(),
                        '\tb\n\t\tc\n\t\tc\n\t\tx\n\td')
       self.assertTodos(todos.subitems[0].subitems[0].yield_following(),
                        '\t\tc\n\t\tc\n\t\tx\n\td')
       self.assertTodos(
           todos.subitems[0].subitems[0].subitems[0].yield_following(),
           '\t\tc\n\t\tx\n\td')
       self.assertTodos(
           todos.subitems[0].subitems[0].subitems[1].yield_following(),
           '\t\tx\n\td')
       self.assertTodos(
           todos.subitems[0].subitems[0].subitems[2].yield_following(), '\td')
       self.assertTodos(todos.subitems[0].subitems[1].yield_following(), '')
Exemplo n.º 18
0
 def test_add_todos_1(self):
     self.assertTodos(
         Todos('- t2') + Todos('i:\n\t-q').subitems[0], '- t2\ni:\n\t-q')
Exemplo n.º 19
0
 def filtering(self, text):
     self.todos = Todos(text)
     return self
Exemplo n.º 20
0
class TestQuery(unittest.TestCase):
    def filtering(self, text):
        self.todos = Todos(text)
        return self

    def by(self, query):
        self.query = '\n\nq:' + query
        self.filtered = self.todos.filter(query)
        return self

    def gives(self, text):
        self.assertEqual(str(self.filtered).strip(), text.strip(), self.query)

    def test_001(self):
        self.filtering("""
- r
- q
""").by('r').gives("""
- r
""")

    def test_002(self):
        self.filtering("""
- r
- q
- w
""").by('r or w').gives("""
- r
- w
""")

    def test_003(self):
        self.filtering("""
- r @a(1)
- q @a(@)
- w @a
""").by('@a = 1').gives("""
- r @a(1)
""")

    def test_004(self):
        self.filtering("""
Inbox:
\t- q @a(@)
\t- w @a
Test:
""").by('project Inbox').gives("""
Inbox:
""")

    def test_005(self):
        self.filtering("""
Inbox:
\t- q @a(@)
\t- w @a
Test:
""").by('project *').gives("""
Inbox:
Test:
""")

    def test_006(self):
        self.filtering("""
Inbox:
\tR:
\tT:
Test:
""").by('/*').gives("""
Inbox:
Test:
""")

    def test_007(self):
        self.filtering("""
Inbox:
\tR:
\tT:
Test
""").by('/project *').gives("""
Inbox:""")

    def test_008(self):
        self.filtering("""
r 0
r 1
r 2
r 3
""").by('r[0]').gives("""
r 0
""")

    def test_009(self):
        self.filtering("""
r 0
r 1
r 2
r 3
""").by('r[1]').gives("""
r 1
""")

    def test_010(self):
        self.filtering("""
r
\tq
\tw
e
\tq
\tw
""").by('r/w').gives("""
r
\tw
""")

    def test_011(self):
        self.filtering("""
r
\tq
\tw
\tw
\t\tl
\tw
\t\tp
e
\tq
\tw
""").by('r/w/p').gives("""
r
\tw
\t\tp
""")

    def test_012(self):
        self.filtering("""
d @due(2016-10-03)
d @due(2016-10-04)
d @due(2016-10-05)
""").by('@due =[d] 2016-10-04').gives("""
d @due(2016-10-04)
""")

    def test_013(self):
        self.filtering("""
r
\tq
\tw
\tw
\t\tl
\tw
\t\tp
\tt
\t\tt
e
\tq
\tw
""").by('r/w/p union t/t').gives("""
r
\tw
\t\tp
\tt
\t\tt
""")

    def test_014(self):
        self.filtering("""
- r 0
- q 1
- r 1
- q 2
\t- r 3
\t- r 4
- r 5
""").by('r[0:3]').gives("""
- r 0
- r 1
- q 2
\t- r 3
""")

    def test_015(self):
        self.filtering("""
d:
\ta @q
\tc
\tb @q
\td
dd:
\ta
\tx @q
""").by('/d/@q[0]').gives("""
d:
\ta @q
dd:
\tx @q
""")

    def test_016(self):
        self.filtering("""
Inbox:
\tR:
\tT:
Test
""").by('//*').gives("""
Inbox:
\tR:
\tT:
""")

    def test_017(self):
        self.filtering("""
Inbox:
\tR:
\tT:
Test
""").by('/*').gives("""
Inbox:
Test
""")

    def test_018(self):
        self.filtering("""
r
\tw
\tq
\tw
\t\tr
\t\tq
\tq
\t\tr
\t\t\tw
""").by('r/w').gives("""
r
\tw
\tw
\tq
\t\tr
\t\t\tw
""")

    def test_019(self):
        self.filtering("""
r
\tq
\t\tw
\tq
w
""").by('r//w').gives("""
r
\tq
\t\tw
""")

    def test_020(self):
        self.filtering("""
r
\tq
\t\tw
\tq
w
""").by('r///w').gives("""
r
\tq
\t\tw
""")

    def test_021(self):
        self.filtering("""
r
\tq 1
\tq 2
r
\tq 3
\tq 4
""").by('r/q[0]').gives("""
r
\tq 1
r
\tq 3
""")

    def test_022(self):
        self.filtering("""
r
r @d
""").by('r except @d').gives("""
r
""")

    def test_023(self):
        self.filtering("""
r
r @d
q @d
""").by('r intersect @d').gives("""
r @d
""")

    def test_024(self):
        self.filtering("""
w
\tr
\t\tr
\t\tb
\tq
\t\tr
\t\ta
""").by('w//*/ancestor-or-self::r').gives("""
w
\tr
\t\tr
\tq
\t\tr
""")

    def test_025(self):
        self.filtering("""
w
\tq
\tr
\t\tx
\t\t\ty
\tq
\t\tx
""").by('w//y/ancestor::r').gives("""
w
\tr
""")

    def test_026(self):
        self.filtering("""
w
\tq
\tr
\t\tq
""").by('w//q/parent::r').gives("""
w
\tr
""")

    def test_027(self):
        self.filtering("""
w
q
r 1
x
r 2
""").by('w/following-sibling::r').gives("""
r 1
r 2
""")

    def test_028(self):
        self.filtering("""
r 0
x
\tw
\t\tr 1
\tr 2
q
r 3
q
""").by('w/following::r').gives("""
x
\tw
\t\tr 1
\tr 2
r 3
""")

    def test_029(self):
        self.filtering("""
r 1
q
r 2
w
""").by('w/preceding-sibling::r').gives("""
r 1
r 2
""")

    def test_030(self):
        self.filtering("""
r 0
x
\tr 1
\t\tq
\t\tr 2
\t\tw
x
\ty
""").by('w/preceding::r').gives("""
r 0
x
\tr 1
\t\tr 2
""")

    def test_031(self):
        self.filtering("""
r
q
\tr
""").by('/ancestor-or-self::r').gives("""
r
q
\tr
""")

    def test_032(self):
        self.filtering("""
r 1
q
\tr
r 2
\tq
""").by('/ancestor::r').gives("""
r 2
""")

    def test_033(self):
        self.filtering("""
r 1
q
\tr 2
r 3
\t q
q
\tr 4
\t\tq
\tw
""").by('/parent::r').gives("""
r 3
q
\tr 4
""")

    def test_034(self):
        self.filtering("""
r 1
q
r 2
w
\tq
\tr 3
""").by('/following-sibling::r').gives("""
r 1
r 2
w
\tr 3
""")

    def test_035(self):
        self.filtering("""
q
r 1
w
\tq
\tr 2
""").by('/following::r').gives("""
r 1
w
\tr 2
""")

    def test_036(self):
        self.filtering("""
q
r 1
w
\tq
\tr 2
\tq
e
\tq
\tr 3
""").by('/preceding-sibling::r').gives("""
r 1
w
\tr 2
""")

    def test_037(self):
        self.filtering("""
r 1
w
\tr 2
\tq
e
\tr 4
""").by('/preceding::r').gives("""
r 1
w
\tr 2
""")

    def test_038(self):
        self.filtering("""
todo:
\tp
to:
\tto
\tto
\tko:
""").by('project *').gives("""
todo:
to:
\tko:
""")

    def test_038b(self):
        items = list(
            Todos("""todo:
\tp
to:
\tto
\tto
\tko:
""").search('project *'))
        self.assertEqual([i.get_text() for i in items],
                         ['todo:', 'to:', '\tko:'])

    def test_039(self):
        self.filtering("""
1 @working
2 @workign @done
3 @done
""").by('@working and not @done').gives("""
1 @working
""")

    def test_039(self):
        self.filtering("""
test @p(eric)
test @p(john,graham)
test @p(graham,eric)
""").by('@p contains[l] john').gives("""
test @p(john,graham)
""")

    def test_039s(self):
        self.filtering("""
test @p(john,graham)
test @p(John,graham)
""").by('@p contains[sl] John').gives("""
test @p(John,graham)
""")

    def test_040(self):
        self.filtering("""
test @p(eric)
test @p(john,graham)
test @p(graham,eric)
""").by('@p contains[l] john,graham').gives("""
test @p(john,graham)
""")

    def test_041(self):
        self.filtering("""
test @p(eric)
test @p(john,graham)
test @p(graham,eric)
""").by('@p contains[l] graham,john').gives("""
test @p(john,graham)
""")

    def test_042(self):
        self.filtering("""
test @p(eric)
test @p(john, graham)
test @p(graham,eric)
""").by('@p contains[l] graham, john').gives("""
test @p(john, graham)
""")

    def test_043(self):
        self.filtering("""
test @p(john, graham)
test @p(graham,john)
""").by('@p =[l] john, graham').gives("""
test @p(john, graham)
""")
Exemplo n.º 21
0
 def test_get(self):
     todos = Todos('a\n\tb')
     subtodos = todos.subitems[0].subitems[0]
     self.assertEqual(todos.get_with_todoitem(subtodos.todoitem), subtodos)
Exemplo n.º 22
0
 def test_get(self):
     todos = Todos('a\n\tb')
     subtodos = todos.subitems[0].subitems[0]
     self.assertEqual(todos.get_with_todoitem(subtodos.todoitem), subtodos)
Exemplo n.º 23
0
class TestQuery(unittest.TestCase):
    def filtering(self, text):
        self.todos = Todos(text)
        return self

    def by(self, query):
        self.query = '\n\nq:' + query
        self.filtered = self.todos.filter(query)
        return self

    def gives(self, text):
        self.assertEqual(str(self.filtered).strip(), text.strip(), self.query)

    def test_001(self):
        self.filtering("""
- r
- q
""").by('r').gives("""
- r
""")

    def test_002(self):
                self.filtering("""
- r
- q
- w
""").by('r or w').gives("""
- r
- w
""")

    def test_003(self):
                self.filtering("""
- r @a(1)
- q @a(@)
- w @a
""").by('@a = 1').gives("""
- r @a(1)
""")

    def test_004(self):
                self.filtering("""
Inbox:
\t- q @a(@)
\t- w @a
Test:
""").by('project Inbox').gives("""
Inbox:
""")


    def test_005(self):
        self.filtering("""
Inbox:
\t- q @a(@)
\t- w @a
Test:
""").by('project *').gives("""
Inbox:
Test:
""")

    def test_006(self):
        self.filtering("""
Inbox:
\tR:
\tT:
Test:
""").by('/*').gives("""
Inbox:
Test:
""")

    def test_007(self):
        self.filtering("""
Inbox:
\tR:
\tT:
Test
""").by('/project *').gives("""
Inbox:""")


    def test_008(self):
        self.filtering("""
r 0
r 1
r 2
r 3
""").by('r[0]').gives("""
r 0
""")

    def test_009(self):
        self.filtering("""
r 0
r 1
r 2
r 3
""").by('r[1]').gives("""
r 1
""")

    def test_010(self):
        self.filtering("""
r
\tq
\tw
e
\tq
\tw
""").by('r/w').gives("""
r
\tw
""")

    def test_011(self):
        self.filtering("""
r
\tq
\tw
\tw
\t\tl
\tw
\t\tp
e
\tq
\tw
""").by('r/w/p').gives("""
r
\tw
\t\tp
""")

    def test_012(self):
        self.filtering("""
d @due(2016-10-03)
d @due(2016-10-04)
d @due(2016-10-05)
""").by('@due =[d] 2016-10-04').gives("""
d @due(2016-10-04)
""")

    def test_013(self):
        self.filtering("""
r
\tq
\tw
\tw
\t\tl
\tw
\t\tp
\tt
\t\tt
e
\tq
\tw
""").by('r/w/p union t/t').gives("""
r
\tw
\t\tp
\tt
\t\tt
""")

    def test_014(self):
        self.filtering("""
- r 0
- q 1
- r 1
- q 2
\t- r 3
\t- r 4
- r 5
""").by('r[0:3]').gives("""
- r 0
- r 1
- q 2
\t- r 3
""")

    def test_015(self):
        self.filtering("""
d:
\ta @q
\tc
\tb @q
\td
dd:
\ta
\tx @q
""").by('/d/@q[0]').gives("""
d:
\ta @q
dd:
\tx @q
""")

    def test_016(self):
        self.filtering("""
Inbox:
\tR:
\tT:
Test
""").by('//*').gives("""
Inbox:
\tR:
\tT:
Test
""")

    def test_017(self):
        self.filtering("""
Inbox:
\tR:
\tT:
Test
""").by('/*').gives("""
Inbox:
Test
""")

    def test_018(self):
        self.filtering("""
r
\tw
\tq
\tw
\t\tr
\t\tq
\tq
\t\tr
\t\t\tw
""").by('r/w').gives("""
r
\tw
\tw
\tq
\t\tr
\t\t\tw
""")

    def test_019(self):
        self.filtering("""
r
\tq
\t\tw
\tq
w
""").by('r//w').gives("""
r
\tq
\t\tw
""")

    def test_020(self):
        self.filtering("""
r
\tq
\t\tw
\tq
w
""").by('r///w').gives("""
r
\tq
\t\tw
""")

    def test_021(self):
        self.filtering("""
r
\tq 1
\tq 2
r
\tq 3
\tq 4
""").by('r/q[0]').gives("""
r
\tq 1
r
\tq 3
""")

    def test_022(self):
        self.filtering("""
r
r @d
""").by('r except @d').gives("""
r
""")

    def test_023(self):
        self.filtering("""
r
r @d
q @d
""").by('r intersect @d').gives("""
r @d
""")

    def test_024(self):
        self.filtering("""
w
\tr
\t\tr
\t\tb
\tq
\t\tr
\t\ta
""").by('w//*/ancestor-or-self::r').gives("""
w
\tr
\t\tr
\tq
\t\tr
""")

    def test_025(self):
        self.filtering("""
w
\tq
\tr
\t\tx
\t\t\ty
\tq
\t\tx
""").by('w//y/ancestor::r').gives("""
w
\tr
""")

    def test_026(self):
        self.filtering("""
w
\tq
\tr
\t\tq
""").by('w//q/parent::r').gives("""
w
\tr
""")

    def test_027(self):
        self.filtering("""
w
q
r 1
x
r 2
""").by('w/following-sibling::r').gives("""
r 1
r 2
""")

    def test_028(self):
        self.filtering("""
r 0
x
\tw
\t\tr 1
\tr 2
q
r 3
q
""").by('w/following::r').gives("""
x
\tw
\t\tr 1
\tr 2
r 3
""")

    def test_029(self):
        self.filtering("""
r 1
q
r 2
w
""").by('w/preceding-sibling::r').gives("""
r 1
r 2
""")

    def test_030(self):
        self.filtering("""
r 0
x
\tr 1
\t\tq
\t\tr 2
\t\tw
x
\ty
""").by('w/preceding::r').gives("""
r 0
x
\tr 1
\t\tr 2
""")

    def test_031(self):
        self.filtering("""
r
q
\tr
""").by('/ancestor-or-self::r').gives("""
""")

    def test_032(self):
        self.filtering("""
r 1
q
\tr
r 2
\tq
""").by('/ancestor::r').gives("""
""")

    def test_033(self):
        self.filtering("""
r 1
q
\tr 2
r 3
\t q
q
\tr 4
\t\tq
\tw
""").by('/parent::r').gives("""
""")

    def test_034(self):
        self.filtering("""
r 1
q
r 2
w
\tq
\tr 3
""").by('/following-sibling::r').gives("""
""")

    def test_035(self):
        self.filtering("""
q
r 1
w
\tq
\tr 2
""").by('/following::r').gives("""
r 1
w
\tr 2
""")

    def test_036(self):
        self.filtering("""
q
r 1
w
\tq
\tr 2
\tq
e
\tq
\tr 3
""").by('/preceding-sibling::r').gives("""
""")

    def test_037(self):
        self.filtering("""
r 1
w
\tr 2
\tq
e
\tr 4
""").by('/preceding::r').gives("""
""")

    def test_038(self):
        self.filtering("""
todo:
\tp
to:
\tto
\tto
\tko:
""").by('project *').gives("""
todo:
to:
\tko:
""")

    def test_038b(self):
        items = list(Todos("""todo:
\tp
to:
\tto
\tto
\tko:
""").search('project *'))
        self.assertEqual([i.get_text() for i in items], ['todo:', 'to:', '\tko:'])

    def test_039(self):
        self.filtering("""
1 @working
2 @workign @done
3 @done
""").by('@working and not @done').gives("""
1 @working
""")
Exemplo n.º 24
0
 def test_add_todos_1(self):
     self.assertTodos(
         Todos('i:\n\t-q').subitems[0] + Todos('- t2'), 'i:\n\t-q\n- t2')
Exemplo n.º 25
0
 def filtering(self, text):
     self.todos = Todos(text)
     return self
Exemplo n.º 26
0
 def test_add_todos(self):
     self.assertTodos(Todos('- t1') + Todos('- t2'), '- t1\n- t2')