from unittest import TestCase, makeSuite, TestSuite |
from unittest import TestCase, makeSuite, TestSuite |
from protocols.advice import * |
from protocols.advice import * |
import sys |
import sys |
|
from types import InstanceType |
|
|
|
|
|
def ping(log, value): |
|
|
|
def pong(klass): |
|
log.append((value,klass)) |
|
return [klass] |
|
|
|
addClassAdvisor(pong) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SuperTest(TestCase): |
class SuperTest(TestCase): |
assert ClassOfSubMeta().foo(1)==2 |
assert ClassOfSubMeta().foo(1)==2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def checkPropSuper(self): |
def checkPropSuper(self): |
|
|
class Base(object): |
class Base(object): |
assert d is globals() |
assert d is globals() |
|
|
|
|
def ping(log, value): |
|
|
|
def pong(klass): |
|
log.append((value,klass)) |
|
return [klass] |
|
|
|
addClassAdvisor(pong) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MROTests(TestCase): |
|
|
|
def checkStdMRO(self): |
|
class foo(object): pass |
|
class bar(foo): pass |
|
class baz(foo): pass |
|
class spam(bar,baz): pass |
|
assert getMRO(spam) is spam.__mro__ |
|
|
|
def checkClassicMRO(self): |
|
class foo: pass |
|
class bar(foo): pass |
|
class baz(foo): pass |
|
class spam(bar,baz): pass |
|
basicMRO = [spam,bar,foo,baz,foo] |
|
assert list(getMRO(spam)) == basicMRO |
|
assert list(getMRO(spam,True)) == basicMRO+[InstanceType,object] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert determineMetaclass((meta,type))==metameta |
assert determineMetaclass((meta,type))==metameta |
|
|
|
|
|
|
|
|
|
|
TestClasses = ( |
TestClasses = ( |
SuperTest, AdviceTests, FrameInfoTest, |
SuperTest, AdviceTests, FrameInfoTest, MROTests, |
) |
) |
|
|
def test_suite(): |
def test_suite(): |
|
|
|
|
|
|
|
|
|
|
|
|