예제 #1
0
def test_make_proxy_cache():
    ip = IProperty(getter=True)
    ip2 = IProperty(setter=True)

    pm = _ProxyManager()
    pm.make_proxy(ip, WeakRef(), {'get': lambda s, o: True, 'toto': 'test'})
    pm.make_proxy(ip2, WeakRef(), {'set': lambda s, o, v: None})

    assert len(pm._proxy_cache) == 1
예제 #2
0
def test_make_proxy_cache():
    ip = IProperty(getter=True)
    ip2 = IProperty(setter=True)

    pm = _ProxyManager()
    pm.make_proxy(ip, WeakRef(), {'get': lambda s, o: True, 'toto': 'test'})
    pm.make_proxy(ip2, WeakRef(), {'set': lambda s, o, v: None})

    assert len(pm._proxy_cache) == 1
예제 #3
0
def test_unpatch():
    ip = IProperty(getter=True)
    ip.get = MethodType(lambda s, o: False, ip)

    pm = _ProxyManager()
    ip_p = pm.make_proxy(ip, WeakRef(),
                         {'get': lambda s, o: True, 'toto': 'test'})

    ip_p.unpatch(['get'])
    assert not ip_p.get(None)
    assert ip_p.toto == 'test'
예제 #4
0
def test_unpatch():
    ip = IProperty(getter=True)
    ip.get = MethodType(lambda s, o: False, ip)

    pm = _ProxyManager()
    ip_p = pm.make_proxy(ip, WeakRef(), {
        'get': lambda s, o: True,
        'toto': 'test'
    })

    ip_p.unpatch(['get'])
    assert not ip_p.get(None)
    assert ip_p.toto == 'test'