Example #1
0
    def test_basestring(self):
        f = filters.msg_filter("^Hello.*$")
        assert callable(f)
        assert f(m)

        f = filters.msg_filter("^Goodbye.*$")
        assert callable(f)
        assert not f(m)
Example #2
0
    def test_regex(self):
        f = filters.msg_filter(re.compile("^Hello.*$"))
        assert callable(f)
        assert f(m)

        f = filters.msg_filter(re.compile("^Goodbye.*$"))
        assert callable(f)
        assert not f(m)
Example #3
0
    def test_regex(self):
        f = filters.msg_filter(re.compile("^Hello.*$"))
        assert callable(f)
        assert f(m)

        f = filters.msg_filter(re.compile("^Goodbye.*$"))
        assert callable(f)
        assert not f(m)
Example #4
0
    def test_bool(self):
        f = filters.msg_filter(True)
        assert callable(f)
        assert f(m)

        f = filters.msg_filter(False)
        assert callable(f)
        assert not f(m)
Example #5
0
    def test_basestring(self):
        f = filters.msg_filter("^Hello.*$")
        assert callable(f)
        assert f(m)

        f = filters.msg_filter("^Goodbye.*$")
        assert callable(f)
        assert not f(m)
Example #6
0
    def test_bool(self):
        f = filters.msg_filter(True)
        assert callable(f)
        assert f(m)

        f = filters.msg_filter(False)
        assert callable(f)
        assert not f(m)
Example #7
0
    def test_list(self):
        re1 = "^Hello.*$"
        re2 = "^.*Funnypants$"
        l = [re1, re2]
        f = filters.msg_filter(l)
        assert callable(f)
        assert f(m)

        re3 = "^.*Sillyhead$"
        l = (re1, re3)
        f = filters.msg_filter(l)
        assert callable(f)
        assert not f(m)
Example #8
0
    def test_list(self):
        re1 = "^Hello.*$"
        re2 = "^.*Funnypants$"
        filter_list = [re1, re2]
        f = filters.msg_filter(filter_list)
        assert callable(f)
        assert f(m)

        re3 = "^.*Sillyhead$"
        filter_tuple = (re1, re3)
        f = filters.msg_filter(filter_tuple)
        assert callable(f)
        assert not f(m)
Example #9
0
 def test_nested_list(self):
     # not encouraged as it's equivalent, but let's support it anyway
     re1 = "^Hello.*$"
     re2 = "^.*Funnypants$"
     filter_list = [re1, [re2]]
     f = filters.msg_filter(filter_list)
     assert callable(f)
     assert f(m)
Example #10
0
 def test_nested_list(self):
     # not encouraged as it's equivalent, but let's support it anyway
     re1 = "^Hello.*$"
     re2 = "^.*Funnypants$"
     l = [re1, [re2]]
     f = filters.msg_filter(l)
     assert callable(f)
     assert f(m)
Example #11
0
 def test_callable(self):
     f = filters.msg_filter(self._always_true)
     assert f is self._always_true
Example #12
0
 def test_None(self):
     f = filters.msg_filter(None)
     assert callable(f)
     assert f(m)
Example #13
0
 def test_None(self):
     f = filters.msg_filter(None)
     assert callable(f)
     assert f(m)
Example #14
0
 def test_bad_arg(self):
     with self.assertRaises(ValueError):
         f = filters.msg_filter(42)
Example #15
0
 def test_callable(self):
     my_func = lambda mesg: True
     f = filters.msg_filter(my_func)
     assert f is my_func
Example #16
0
 def test_bad_arg(self):
     with self.assertRaises(ValueError):
         filters.msg_filter(42)
Example #17
0
 def test_single_list(self):
     re1 = "^Hello.*$"
     l = [re1]
     f = filters.msg_filter(l)
     assert callable(f)
     assert f(m)
Example #18
0
 def test_callable(self):
     my_func = lambda mesg: True
     f = filters.msg_filter(my_func)
     assert f is my_func
Example #19
0
 def test_single_list(self):
     re1 = "^Hello.*$"
     filter_list = [re1]
     f = filters.msg_filter(filter_list)
     assert callable(f)
     assert f(m)
Example #20
0
 def test_callable(self):
     f = filters.msg_filter(self._always_true)
     assert f is self._always_true