6.2.3.3. Test

Start python section to interscript/tests/test_protocol.py[1 /1 ]
     1: #line 151 "protocols.ipk"
     2: #-------------- test_protocol.py ---------------------------
     3: import types
     4: import interscript.core.protocols
     5: protocol = interscript.core.protocols
     6: assert protocol.has_protocol(types.IntType,types.TypeType)
     7: assert protocol.has_protocol(1,types.IntType)
     8: assert protocol.has_protocol(1,'integer')
     9: 
    10: class B:
    11:   def __init__(self):
    12:     self.fred = 1
    13: 
    14: class D(B): pass
    15: d = D()
    16: 
    17: protocol.add_class_proto(B,'B')
    18: protocol.add_class_proto(D,'D')
    19: protocol.add_obj_proto(d,'d')
    20: protocol.add_type_proto(types.InstanceType,'my instance')
    21: 
    22: assert protocol.has_protocol(d,'B')
    23: assert protocol.has_protocol(d,'D')
    24: assert protocol.has_protocol(d,'d')
    25: assert protocol.has_protocol(d,'instance')
    26: assert protocol.has_protocol(d,'my instance')
    27: assert protocol.has_protocol(d,protocol.provides_attr('fred'))
    28: 
End python section to interscript/tests/test_protocol.py[1]
Start output section of "/usr/local/bin/python" interscript/tests/test_protocol.py
     1: 
End output section to "/usr/local/bin/python" interscript/tests/test_protocol.py