def test_data_model(self):
        foo = lambda x, y: x
        bar = lambda x, y: x
        baz = lambda x, y: x
        fl = filterlist()

        fl.extend([foo, bar])
        self.assertEquals(len(fl), 2)
        self.assertTrue(foo in fl)

        fl.append(baz)
        self.assertEquals(fl[2], baz)

        fl.remove(baz)
        self.assertFalse(baz in fl)

        item = fl.pop()
        self.assertEquals(item, bar)

        self.assertEquals(fl.index(foo), 0)

        del fl[0]
        self.assertFalse(foo in fl)
        with self.assertRaises(IndexError):
            fl[0]
    def test_add_two_tags_filters(self):
        tag1 = tags('foo')
        tag2 = tags('bar')
        fl = filterlist([tag1])

        with self.assertRaises(ValueError):
            fl.append(tag1)

        fl.append(tag2)
        self.assertEquals(len(fl), 2)
    def test_filters_run_in_order(self):
        a = lambda x, y: x
        b = lambda x, y: x
        c = lambda x, y: x
        d = lambda x, y: x
        e = lambda x, y: x
        f = lambda x, y: x

        fl = filterlist([a, b])
        fl.append(c)
        fl.extend([d, e])
        fl += [f]
        self.assertEquals([i for i in fl], [a, b, c, d, e, f])
    def test_add_duplicates_to_list(self):
        foo = lambda x, y: x
        bar = lambda x, y: x
        sub = subsuite('foo')
        fl = filterlist([foo, bar, sub])
        self.assertEquals(len(fl), 3)
        self.assertEquals(fl[0], foo)

        with self.assertRaises(ValueError):
            fl.append(foo)

        with self.assertRaises(ValueError):
            fl.append(subsuite('bar'))
def test_add_duplicates_to_list():
    foo = lambda x, y: x
    bar = lambda x, y: x
    sub = subsuite('foo')
    fl = filterlist([foo, bar, sub])
    assert len(fl) == 3
    assert fl[0] == foo

    with pytest.raises(ValueError):
        fl.append(foo)

    with pytest.raises(ValueError):
        fl.append(subsuite('bar'))
Beispiel #6
0
    def test_filters_run_in_order(self):
        a = lambda x, y: x
        b = lambda x, y: x
        c = lambda x, y: x
        d = lambda x, y: x
        e = lambda x, y: x
        f = lambda x, y: x

        fl = filterlist([a, b])
        fl.append(c)
        fl.extend([d, e])
        fl += [f]
        self.assertEquals([i for i in fl], [a, b, c, d, e, f])
Beispiel #7
0
    def test_add_duplicates_to_list(self):
        foo = lambda x, y: x
        bar = lambda x, y: x
        sub = subsuite('foo')
        fl = filterlist([foo, bar, sub])
        self.assertEquals(len(fl), 3)
        self.assertEquals(fl[0], foo)

        with self.assertRaises(ValueError):
            fl.append(foo)

        with self.assertRaises(ValueError):
            fl.append(subsuite('bar'))
Beispiel #8
0
def test_add_duplicates_to_list():
    def foo(x, y):
        return x

    def bar(x, y):
        return x

    sub = subsuite("foo")
    fl = filterlist([foo, bar, sub])
    assert len(fl) == 3
    assert fl[0] == foo

    with pytest.raises(ValueError):
        fl.append(foo)

    with pytest.raises(ValueError):
        fl.append(subsuite("bar"))
Beispiel #9
0
def test_filters_run_in_order():
    def a(x, y):
        return x

    def b(x, y):
        return x

    def c(x, y):
        return x

    def d(x, y):
        return x

    def e(x, y):
        return x

    def f(x, y):
        return x

    fl = filterlist([a, b])
    fl.append(c)
    fl.extend([d, e])
    fl += [f]
    assert [i for i in fl] == [a, b, c, d, e, f]
Beispiel #10
0
 def test_add_non_callable_to_set(self):
     fl = filterlist()
     with self.assertRaises(TypeError):
         fl.append('foo')
Beispiel #11
0
 def test_add_non_callable_to_list(self):
     fl = filterlist()
     with self.assertRaises(TypeError):
         fl.append('foo')
Beispiel #12
0
def test_add_non_callable_to_list():
    fl = filterlist()
    with pytest.raises(TypeError):
        fl.append("foo")