Commit 59452903 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Properly deal with integers passed as expression.

parent 37aba451
......@@ -186,6 +186,13 @@ class FilterTest(TopydoTest.TopydoTest):
todolist_to_string(reference))
def test_filter19(self):
todos = load_file('test/data/FilterTest1.txt')
grep = Filter.GrepFilter(1)
filtered_todos = grep.filter(todos)
self.assertEquals(filtered_todos, [])
def test_filter20(self):
todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('due:<2014-11-10')
......@@ -195,7 +202,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos), \
todolist_to_string(reference))
def test_filter20(self):
def test_filter21(self):
todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('due:=2014-11-10')
......@@ -203,7 +210,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos), "")
def test_filter21(self):
def test_filter22(self):
todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('due:=2014-11-10')
......@@ -211,7 +218,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos), "")
def test_filter22(self):
def test_filter23(self):
todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('due:=2014-11-99')
......@@ -219,7 +226,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos), "")
def test_filter23(self):
def test_filter24(self):
todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('due:=garbage')
......@@ -227,7 +234,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos), "")
def test_filter24(self):
def test_filter25(self):
todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:<10')
......@@ -237,7 +244,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos),
todolist_to_string(reference))
def test_filter25(self):
def test_filter26(self):
todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:<=16')
......@@ -247,7 +254,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos),
todolist_to_string(reference))
def test_filter26(self):
def test_filter27(self):
todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:<16')
......@@ -257,7 +264,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos),
todolist_to_string(reference))
def test_filter27(self):
def test_filter28(self):
todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:<16a')
......@@ -265,7 +272,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos), "")
def test_filter28(self):
def test_filter29(self):
todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:>8')
......@@ -275,7 +282,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos),
todolist_to_string(reference))
def test_filter29(self):
def test_filter30(self):
todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:>=8')
......@@ -285,7 +292,7 @@ class FilterTest(TopydoTest.TopydoTest):
self.assertEquals(todolist_to_string(filtered_todos),
todolist_to_string(reference))
def test_filter30(self):
def test_filter31(self):
todos = load_file('test/data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:>-8')
......
......@@ -62,7 +62,8 @@ class GrepFilter(Filter):
def __init__(self, p_expression, p_case_sensitive=None):
super(GrepFilter, self).__init__()
self.expression = p_expression
# convert to string in case we receive integers
self.expression = str(p_expression)
if p_case_sensitive != None:
self.case_sensitive = p_case_sensitive
......@@ -70,7 +71,7 @@ class GrepFilter(Filter):
# only be case sensitive when the expression contains at least one
# capital character.
self.case_sensitive = \
len([c for c in p_expression if c.isupper()]) > 0
len([c for c in self.expression if c.isupper()]) > 0
def match(self, p_todo):
expr = self.expression
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment