class CollectionProxyTestCase(TestCase): @setup def setup_proxy(self): self.target_list = [DummyTarget(1), DummyTarget(2), DummyTarget(0)] self.proxy = CollectionProxy( lambda: self.target_list, [ ('foo', any, True), ('not_foo', all, False), ('equals', lambda a: list(a), True), ], ) self.dummy = DummyObject(self.proxy) def test_add(self): self.proxy.add('foo', any, True) assert_equal(self.proxy._defs['foo'], (any, True)) def test_perform(self): assert self.dummy.foo() assert not self.dummy.not_foo def test_perform_not_defined(self): assert_raises(AttributeError, self.dummy.proxy.perform, 'bar') def test_perform_with_params(self): assert_equal(self.proxy.perform('equals')(2), [False, True, False]) sometimes = ['sometimes'] * 3 assert_equal( self.proxy.perform('equals')(3, sometimes=True), sometimes, )
class CollectionProxyTestCase(TestCase): @setup def setup_proxy(self): self.target_list = [DummyTarget(1), DummyTarget(2), DummyTarget(0)] self.proxy = CollectionProxy(lambda: self.target_list, [ ('foo', any, True), ('not_foo', all, False), ('equals', lambda a: list(a), True) ]) self.dummy = DummyObject(self.proxy) def test_add(self): self.proxy.add('foo', any, True) assert_equal(self.proxy._defs['foo'], (any, True)) def test_perform(self): assert self.dummy.foo() assert not self.dummy.not_foo def test_perform_not_defined(self): assert_raises(AttributeError, self.dummy.proxy.perform, 'bar') def test_perform_with_params(self): assert_equal(self.proxy.perform('equals')(2), [False, True, False]) sometimes = ['sometimes'] * 3 assert_equal(self.proxy.perform('equals')(3, sometimes=True), sometimes)
def setup_proxy(self): self.target_list = [DummyTarget(1), DummyTarget(2), DummyTarget(0)] self.proxy = CollectionProxy(lambda: self.target_list, [('foo', any, True), ('not_foo', all, False), ('equals', lambda a: list(a), True)]) self.dummy = DummyObject(self.proxy)
def setup_proxy(self): self.target_list = [DummyTarget(1), DummyTarget(2), DummyTarget(0)] self.proxy = CollectionProxy(lambda: self.target_list, [ ('foo', any, True), ('not_foo', all, False), ('equals', lambda a: list(a), True) ]) self.dummy = DummyObject(self.proxy)