Test: Corrected broken tests

This commit is contained in:
Paul Beckingham 2015-07-04 17:02:36 -04:00
parent 0572db902d
commit 07c76b208e

View file

@ -41,17 +41,17 @@ class TestFilter(TestCase):
def setUpClass(cls):
cls.t = Task()
cls.t(("add", "project:A", "prio:H", "+tag", "one", "foo"))
cls.t(("add", "project:A", "prio:H", "two"))
cls.t(("add", "project:A", "three"))
cls.t(("add", "prio:H", "four"))
cls.t(("add", "+tag", "five"))
cls.t(("add", "six", "foo"))
cls.t(("add", "prio:L", "seven", "bar", "foo"))
cls.t("add project:A prio:H +tag one foo")
cls.t("add project:A prio:H two")
cls.t("add project:A three")
cls.t("add prio:H four")
cls.t("add +tag five")
cls.t("add six foo")
cls.t("add prio:L seven bar foo")
def test_list(self):
"""filter - list"""
code, out, err = self.t(("list",))
code, out, err = self.t("list")
self.assertIn("one", out)
self.assertIn("two", out)
@ -63,7 +63,7 @@ class TestFilter(TestCase):
def test_list_projectA(self):
"""filter - list project:A"""
code, out, err = self.t(("list", "project:A"))
code, out, err = self.t("list project:A")
self.assertIn("one", out)
self.assertIn("two", out)
@ -75,7 +75,7 @@ class TestFilter(TestCase):
def test_list_priorityH(self):
"""filter - list priority:H"""
code, out, err = self.t(("list", "priority:H"))
code, out, err = self.t("list priority:H")
self.assertIn("one", out)
self.assertIn("two", out)
@ -87,7 +87,7 @@ class TestFilter(TestCase):
def test_list_priority(self):
"""filter - list priority:"""
code, out, err = self.t(("list", "priority:"))
code, out, err = self.t("list priority:")
self.assertNotIn("one", out)
self.assertNotIn("two", out)
@ -99,7 +99,7 @@ class TestFilter(TestCase):
def test_list_substring(self):
"""filter - list /foo/"""
code, out, err = self.t(("list", "/foo/"))
code, out, err = self.t("list /foo/")
self.assertIn("one", out)
self.assertNotIn("two", out)
@ -111,7 +111,7 @@ class TestFilter(TestCase):
def test_list_double_substring(self):
"""filter - list /foo/ /bar/"""
code, out, err = self.t(("list", "/foo/", "/bar/"))
code, out, err = self.t("list /foo/ /bar/")
self.assertNotIn("one", out)
self.assertNotIn("two", out)
@ -123,7 +123,7 @@ class TestFilter(TestCase):
def test_list_include_tag(self):
"""filter - list +tag"""
code, out, err = self.t(("list", "+tag"))
code, out, err = self.t("list +tag")
self.assertIn("one", out)
self.assertNotIn("two", out)
@ -135,7 +135,7 @@ class TestFilter(TestCase):
def test_list_exclude_tag(self):
"""filter - list -tag"""
code, out, err = self.t(("list", "-tag"))
code, out, err = self.t("list -tag")
self.assertNotIn("one", out)
self.assertIn("two", out)
@ -147,7 +147,7 @@ class TestFilter(TestCase):
def test_list_non_existing_tag(self):
"""filter - list -missing"""
code, out, err = self.t(("list", "-missing"))
code, out, err = self.t("list -missing")
self.assertIn("one", out)
self.assertIn("two", out)
@ -159,7 +159,7 @@ class TestFilter(TestCase):
def test_list_mutually_exclusive_tag(self):
"""filter - list +tag -tag"""
code, out, err = self.t.runError(("list", "+tag", "-tag"))
code, out, err = self.t.runError("list +tag -tag")
self.assertNotIn("one", out)
self.assertNotIn("two", out)
@ -171,7 +171,7 @@ class TestFilter(TestCase):
def test_list_projectA_priorityH(self):
"""filter - list project:A priority:H"""
code, out, err = self.t(("list", "project:A", "priority:H"))
code, out, err = self.t("list project:A priority:H")
self.assertIn("one", out)
self.assertIn("two", out)
@ -183,7 +183,7 @@ class TestFilter(TestCase):
def test_list_projectA_priority(self):
"""filter - list project:A priority:"""
code, out, err = self.t(("list", "project:A", "priority:"))
code, out, err = self.t("list project:A priority:")
self.assertNotIn("one", out)
self.assertNotIn("two", out)
@ -195,7 +195,7 @@ class TestFilter(TestCase):
def test_list_projectA_substring(self):
"""filter - list project:A /foo/"""
code, out, err = self.t(("list", "project:A", "/foo/"))
code, out, err = self.t("list project:A /foo/")
self.assertIn("one", out)
self.assertNotIn("two", out)
@ -207,7 +207,7 @@ class TestFilter(TestCase):
def test_list_projectA_tag(self):
"""filter - list project:A +tag"""
code, out, err = self.t(("list", "project:A", "+tag"))
code, out, err = self.t("list project:A +tag")
self.assertIn("one", out)
self.assertNotIn("two", out)
@ -219,7 +219,7 @@ class TestFilter(TestCase):
def test_list_projectA_priorityH_substring(self):
"""filter - list project:A priority:H /foo/"""
code, out, err = self.t(("list", "project:A", "priority:H", "/foo/"))
code, out, err = self.t("list project:A priority:H /foo/")
self.assertIn("one", out)
self.assertNotIn("two", out)
@ -231,7 +231,7 @@ class TestFilter(TestCase):
def test_list_projectA_priorityH_tag(self):
"""filter - list project:A priority:H +tag"""
code, out, err = self.t(("list", "project:A", "priority:H", "+tag"))
code, out, err = self.t("list project:A priority:H +tag")
self.assertIn("one", out)
self.assertNotIn("two", out)
@ -243,8 +243,7 @@ class TestFilter(TestCase):
def test_list_projectA_priorityH_substring_tag(self):
"""filter - list project:A priority:H /foo/ +tag"""
code, out, err = self.t(("list", "project:A", "priority:H", "/foo/",
"+tag"))
code, out, err = self.t("list project:A priority:H /foo/ +tag")
self.assertIn("one", out)
self.assertNotIn("two", out)
@ -256,8 +255,7 @@ class TestFilter(TestCase):
def test_list_projectA_priorityH_substring_tag_substring(self):
"""filter - list project:A priority:H /foo/ +tag /baz/"""
code, out, err = self.t.runError(("list", "project:A", "priority:H",
"/foo/", "+tag", "/baz/"))
code, out, err = self.t.runError("list project:A priority:H /foo/ +tag /baz/")
self.assertNotIn("one", out)
self.assertNotIn("two", out)
@ -267,10 +265,9 @@ class TestFilter(TestCase):
self.assertNotIn("six", out)
self.assertNotIn("seven", out)
@unittest.expectedFailure
def test_regex_list_project(self):
"""filter - rc.regex:on list project~[A-Z]"""
code, out, err = self.t(("rc.regex:on", "list", "project~[A-Z]"))
"""filter - rc.regex:on list project ~ [A-Z]"""
code, out, err = self.t("rc.regex:on list project ~ [A-Z]")
self.assertIn("one", out)
self.assertIn("two", out)
@ -282,7 +279,7 @@ class TestFilter(TestCase):
def test_regex_list_project_any(self):
"""filter - rc.regex:on list project~."""
code, out, err = self.t(("rc.regex:on", "list", "project~."))
code, out, err = self.t("rc.regex:on list project ~ .")
self.assertIn("one", out)
self.assertIn("two", out)
@ -294,7 +291,7 @@ class TestFilter(TestCase):
def test_regex_list_substring(self):
"""filter - rc.regex:on list /fo{2}/"""
code, out, err = self.t(("rc.regex:on", "list", "/fo{2}/"))
code, out, err = self.t("rc.regex:on list /fo{2}/")
self.assertIn("one", out)
self.assertNotIn("two", out)
@ -306,7 +303,7 @@ class TestFilter(TestCase):
def test_regex_list_double_substring_wildcard(self):
"""filter - rc.regex:on list /f../ /b../"""
code, out, err = self.t(("rc.regex:on", "list", "/f../", "/b../"))
code, out, err = self.t("rc.regex:on list /f../ /b../")
self.assertNotIn("one", out)
self.assertNotIn("two", out)
@ -318,7 +315,7 @@ class TestFilter(TestCase):
def test_regex_list_substring_startswith(self):
"""filter - rc.regex:on list /^s/"""
code, out, err = self.t(("rc.regex:on", "list", "/^s/"))
code, out, err = self.t("rc.regex:on list /^s/")
self.assertNotIn("one", out)
self.assertNotIn("two", out)
@ -330,7 +327,7 @@ class TestFilter(TestCase):
def test_regex_list_substring_wildcard_startswith(self):
"""filter - rc.regex:on list /^.i/"""
code, out, err = self.t(("rc.regex:on", "list", "/^.i/"))
code, out, err = self.t("rc.regex:on list /^.i/")
self.assertNotIn("one", out)
self.assertNotIn("two", out)
@ -342,7 +339,7 @@ class TestFilter(TestCase):
def test_regex_list_substring_or(self):
"""filter - rc.regex:on list /two|five/"""
code, out, err = self.t(("rc.regex:on", "list", "/two|five/"))
code, out, err = self.t("rc.regex:on list /two|five/")
self.assertNotIn("one", out)
self.assertIn("two", out)
@ -357,7 +354,7 @@ class TestFilterDue(TestCase):
def setUp(self):
self.t = Task()
self.t.config("due", "4")
self.t.config("due", "4")
self.t.config("dateformat", "m/d/Y")
just = datetime.now() + timedelta(days=3)
@ -369,16 +366,16 @@ class TestFilterDue(TestCase):
def test_due_filter(self):
"""due tasks filtered correctly"""
self.t(("add", "one", "due:{0}".format(self.just)))
self.t(("add", "two", "due:{0}".format(self.almost)))
self.t(("add", "three", "due:today"))
self.t("add one due:{0}".format(self.just))
self.t("add two due:{0}".format(self.almost))
self.t("add three due:today")
code, out, err = self.t(("list", "due:today"))
code, out, err = self.t("list due:today")
self.assertNotIn("one", out)
self.assertNotIn("two", out)
self.assertIn("three", out)
code, out, err = self.t(("list", "due.is:today"))
code, out, err = self.t("list due.is:today")
self.assertNotIn("one", out)
self.assertNotIn("two", out)
self.assertIn("three", out)
@ -390,13 +387,13 @@ class TestBug1110(TestCase):
def test_status_is_case_insensitive(self):
"""filter - status:Completed / status:completed - behave the same"""
self.t(("add", "ToBeCompleted"))
self.t(("1", "done"))
self.t("add ToBeCompleted")
self.t("1 done")
code, out, err = self.t(("all", "status:Completed"))
code, out, err = self.t("all status:Completed")
self.assertIn("ToBeCompleted", out)
code, out, err = self.t(("all", "status:completed"))
code, out, err = self.t("all status:completed")
self.assertIn("ToBeCompleted", out)
@ -407,30 +404,30 @@ class TestBug480A(TestCase):
cls.t.config("defaultwidth", "0")
cls.t(("add", "one", "+ordinary"))
cls.t(("add", "two", "+@strange"))
cls.t("add one +ordinary")
cls.t("add two +@strange")
def test_long_plus_ordinary(self):
"""filter '@' in tags breaks filters: +ordinary"""
code, out, err = self.t(("long", "+ordinary"))
code, out, err = self.t("long +ordinary")
self.assertIn("one", out)
self.assertNotIn("two", out)
def test_long_minus_ordinary(self):
"""filter '@' in tags breaks filters: -ordinary"""
code, out, err = self.t(("long", "-ordinary"))
code, out, err = self.t("long -ordinary")
self.assertNotIn("one", out)
self.assertIn("two", out)
def test_long_plus_at_strange(self):
"""filter '@' in tags breaks filters: +@strange"""
code, out, err = self.t(("long", "+@strange"))
code, out, err = self.t("long +@strange")
self.assertNotIn("one", out)
self.assertIn("two", out)
def test_long_minus_at_strange(self):
"""filter '@' in tags breaks filters: -@strange"""
code, out, err = self.t(("long", "-@strange"))
code, out, err = self.t("long -@strange")
self.assertIn("one", out)
self.assertNotIn("two", out)
@ -441,23 +438,23 @@ class TestBug480B(TestCase):
self.t.config("defaultwidth", "0")
self.t(("add", "one", "+t1"))
self.t(("add", "two", "+t2"))
self.t(("add", "three", "+t3"))
self.t("add one +t1")
self.t("add two +t2")
self.t("add three +t3")
def test_numbered_tags(self):
"""filter '-t1 -t2' doesn't work"""
code, out, err = self.t(("list", "-t1"))
code, out, err = self.t("list -t1")
self.assertNotIn("one", out)
self.assertIn("two", out)
self.assertIn("three", out)
code, out, err = self.t(("list", "-t1", "-t2"))
code, out, err = self.t("list -t1 -t2")
self.assertNotIn("one", out)
self.assertNotIn("two", out)
self.assertIn("three", out)
code, out, err = self.t.runError(("list", "-t1", "-t2", "-t3"))
code, out, err = self.t.runError("list -t1 -t2 -t3")
self.assertIn("No matches", err)
self.assertNotIn("one", out)
self.assertNotIn("two", out)
@ -465,21 +462,21 @@ class TestBug480B(TestCase):
def test_numbered_at_tags(self):
"""filter '-t1 -t2' doesn't work when '@' characters are involved"""
self.t(("1", "modify", "+@1"))
self.t(("2", "modify", "+@2"))
self.t(("3", "modify", "+@3"))
self.t("1 modify +@1")
self.t("2 modify +@2")
self.t("3 modify +@3")
code, out, err = self.t(("list", "-@1"))
code, out, err = self.t("list -@1")
self.assertNotIn("one", out)
self.assertIn("two", out)
self.assertIn("three", out)
code, out, err = self.t(("list", "-@1", "-@2"))
code, out, err = self.t("list -@1 -@2")
self.assertNotIn("one", out)
self.assertNotIn("two", out)
self.assertIn("three", out)
code, out, err = self.t.runError(("list", "-@1", "-@2", "-@3"))
code, out, err = self.t.runError("list -@1 -@2 -@3")
self.assertIn("No matches", err)
self.assertNotIn("one", out)
self.assertNotIn("two", out)
@ -487,22 +484,21 @@ class TestBug480B(TestCase):
def test_numbered_at_tags_punctuation(self):
"""filter '-t1 -t2' doesn't work with '@' characters and punctuation"""
self.t(("1", "modify", "+@foo.1"))
self.t(("2", "modify", "+@foo.2"))
self.t(("3", "modify", "+@foo.3"))
self.t("1 modify +@foo.1")
self.t("2 modify +@foo.2")
self.t("3 modify +@foo.3")
code, out, err = self.t(("list", "-@foo.1"))
code, out, err = self.t("list -@foo.1")
self.assertNotIn("one", out)
self.assertIn("two", out)
self.assertIn("three", out)
code, out, err = self.t(("list", "-@foo.1", "-@foo.2"))
code, out, err = self.t("list -@foo.1 -@foo.2")
self.assertNotIn("one", out)
self.assertNotIn("two", out)
self.assertIn("three", out)
code, out, err = self.t.runError(("list", "-@foo.1", "-@foo.2",
"-@foo.3"))
code, out, err = self.t.runError("list -@foo.1 -@foo.2 -@foo.3")
self.assertIn("No matches", err)
self.assertNotIn("one", out)
self.assertNotIn("two", out)
@ -516,18 +512,18 @@ class TestBug485(TestCase):
cls.t.config("verbose", "nothing")
cls.t(("add", "one", "due:tomorrow", "recur:monthly"))
cls.t(("add", "two", "due:tomorrow", "recur:1month"))
cls.t("add one due:tomorrow recur:monthly")
cls.t("add two due:tomorrow recur:1month")
def test_filter_recur_monthly(self):
"""filter 'recur:monthly' doesn't list monthly tasks"""
code, out, err = self.t(("list", "recur:monthly"))
code, out, err = self.t("list recur:monthly")
self.assertIn("one", out)
self.assertIn("two", out)
def test_filter_recur_1month(self):
"""filter 'recur:1month' doesn't list monthly tasks"""
code, out, err = self.t(("list", "recur:1month"))
code, out, err = self.t("list recur:1month")
self.assertIn("one", out)
self.assertIn("two", out)
@ -539,58 +535,58 @@ class TestBug489(TestCase):
def test_filter_tagless_tasks(self):
"""tags.none: filters tagless tasks"""
self.t(("add", "with", "+tag"))
self.t(("add", "without"))
self.t("add with +tag")
self.t("add without")
code, out, err = self.t(("list", "tags.none:"))
code, out, err = self.t("list tags.none:")
self.assertNotIn("with ", out)
self.assertIn("without", out)
@unittest.skip("WaitingFor TW-1600")
#@unittest.skip("WaitingFor TW-1600")
class TestBug1600(TestCase):
def setUp(self):
self.t = Task()
def test_filter_plus_in_descriptions(self):
"""filter - description contains +"""
self.t(("add", "foobar1"))
self.t(("add", "foobar2"))
self.t(("add", "foobar+"))
self.t("add foobar1")
self.t("add foobar2")
self.t("add foobar+")
code, out, err = self.t(("all",))
code, out, err = self.t("all")
self.assertIn("foobar+", out)
self.assertIn("foobar1", out)
self.assertIn("foobar2", out)
code, out, err = self.t(("all", "description.contains:'foobar+'"))
code, out, err = self.t("all description.contains:'foobar\\+'")
self.assertIn("foobar+", out)
self.assertNotIn("foobar1", out)
self.assertNotIn("foobar2", out)
def test_filter_question_in_descriptions(self):
"""filter - description contains ? """
self.t(("add", "foobar1"))
self.t(("add", "foo?bar"))
self.t("add foobar1")
self.t("add foo?bar")
code, out, err = self.t(("all",))
code, out, err = self.t("all")
self.assertIn("foobar1", out)
self.assertIn("foo?bar", out)
code, out, err = self.t(("all", "description.contains:'foo?bar'"))
code, out, err = self.t("all description.contains:'foo\\?bar'")
self.assertIn("foo?bar", out)
self.assertNotIn("foobar1", out)
def test_filter_brackets_in_descriptions(self):
"""filter - description contains [] """
self.t(("add", "[foobar1]"))
self.t(("add", "[foobar2]"))
self.t("add [foobar1]")
self.t("add [foobar2]")
code, out, err = self.t(("all",))
code, out, err = self.t("all")
self.assertIn("[foobar1]", out)
self.assertIn("[foobar2]", out)
code, out, err = self.t(("all", "description.contains:'[foobar]'"))
code, out, err = self.t("all description.contains:'\\[foobar1\\]'")
self.assertIn("[foobar1]", out)
self.assertNotIn("[foobar2]", out)