예제 #1
0
# !/usr/env/python python
# -*- coding: utf8 -*-

from prototype import Prototype


class A(object):
    CLONED = False

    def __init__(self, *args):
        self.args = args

    def is_cloned(self):
        return self.CLONED


class B(A):
    pass


registered_objs = Prototype()

registered_objs.reg_obj('A', A)
b = registered_objs.clone('A')

print A().is_cloned()
print B().is_cloned()
print B.__name__
print B().ARG
예제 #2
0
# !/usr/env/python python
# -*- coding: utf8 -*-

from prototype import Prototype


class A(object):
    CLONED = False

    def __init__(self, *args):
        self.args = args

    def is_cloned(self):
        return self.CLONED


class B(A):
    pass


registered_objs = Prototype()

registered_objs.reg_obj("A", A)
b = registered_objs.clone("A")

print A().is_cloned()
print B().is_cloned()
print B.__name__
print B().ARG
예제 #3
0
 def test_clone(self):
     object1 = Prototype("object")
     object2 = object1.clone()
     self.assertEqual(object1.name, object2.name)
     self.assertNotEqual(id(object1), id(object2))