def testRegisterFreezableClassmap(self): class Freezable(object): def __freeze__(self): return {} @classmethod def __thaw__(class_, d): return class_() class Foo(Freezable): pass class Bar(Freezable): pass apiutils.register_freezable_classmap("mytype", Foo) apiutils.register_freezable_classmap("mytype", Bar) assert apiutils.thaw("mytype", apiutils.freeze("mytype", Foo())).__class__ == Foo assert apiutils.thaw("mytype", apiutils.freeze("mytype", Bar())).__class__ == Bar
def testRegisterFreezableClassmap(self): class Freezable(object): def __freeze__(self): return {} @classmethod def __thaw__(class_, d): return class_() class Foo(Freezable): pass class Bar(Freezable): pass apiutils.register_freezable_classmap('mytype', Foo) apiutils.register_freezable_classmap('mytype', Bar) assert (apiutils.thaw('mytype', apiutils.freeze('mytype', Foo())).__class__ == Foo) assert (apiutils.thaw('mytype', apiutils.freeze('mytype', Bar())).__class__ == Bar)
def __init__(class_, *args, **kw): type.__init__(class_, *args, **kw) _troveClassesByType[class_.troveType] = class_ apiutils.register_freezable_classmap('BuildTrove', class_)
def __init__(class_, *args, **kw): type.__init__(class_, *args, **kw) _troveClassesByType[class_.troveType] = class_ apiutils.register_freezable_classmap("BuildTrove", class_)
def __init__(class_, *args, **kw): type.__init__(class_, *args, **kw) apiutils.register_freezable_classmap('TroveSettings', class_)