def test_class_and_method_str_attr(self): class TestP(object): foo = 'a' def h(self): pass h.foo = 'b' def i(): pass i.foo = 'a' plug = AttributeSelector() plug.attribs = [[('foo', 'a'), ('foo', 'b')]] assert plug.wantMethod(unbound_method(TestP, TestP.h)) is not False assert plug.wantFunction(i) is False plug.attribs = [[('foo', 'b')]] assert plug.wantMethod(unbound_method(TestP, TestP.h)) is not False assert plug.wantFunction(i) is False
def test_basic_attr(self): def f(): pass f.a = 1 def g(): pass plug = AttributeSelector() plug.attribs = [[('a', True)]] assert plug.wantFunction(f) is not False assert not plug.wantFunction(g)
def test_class_attr(self): class TestP: foo = True def h(): pass def i(): pass plug = AttributeSelector() plug.attribs = [[('foo', True)]] assert plug.wantMethod(unbound_method(TestP, TestP.h)) is not False assert plug.wantFunction(i) is False