Ejemplo n.º 1
0
 def __init__(self,num_s,num_q):
     students = self.gen_students(num_s)
     print ("\n\n\n Standard Test \n\n")
     newTest = Test(num_q, students)
     newTest.start()
     newTest.printResult()
     print ("\n\n\n Optimized Test \n\n")
     optTest = Test(num_q, students)
     optTest.start_opt()
     optTest.printResult()
Ejemplo n.º 2
0
def execute(*args):
    """Test all derived functions for proper operation
    
    """
    
    import Vector
    reload(Vector)
    Vector.test()
    
    import Add
    reload(Add)
    Add.test()
    
    import Multiply
    reload(Multiply)
    Multiply.test()
    
    import Divide
    reload(Divide)
    Divide.test()
    
    import Difference
    reload(Difference)
    Difference.test()
    
    import Poly
    reload(Poly)
    Poly.test()
    
    import Average
    reload(Average)
    Average.test()
    
    import LinTrans
    reload(LinTrans)
    LinTrans.test()
    
    import Test
    reload(Test)
    Test.test()
    
    import Rotate
    reload(Rotate)
    Rotate.test()
    
    import Magnitude
    reload(Magnitude)
    Magnitude.test()
    
    import Cape
    reload(Cape)
    Cape.test()
    
    print "-"*60
    print "Function Test Complete"
Ejemplo n.º 3
0
	def post(self):
		if 'Save' in flask.request.form:
			template_id = request.form['template_id']
			modified_template_body = request.form['template_body']
			print "\najjsj\n"
			Test.test_session_variable()
			print modified_template_body
			print template_id
			
			g.db.execute('update list_templates SET template_body=\"'+modified_template_body+'\" where id='+template_id)
			g.db.commit()
			flask.flash('New entry was successfully saved')
			return flask.redirect(flask.url_for('show_templates'))
Ejemplo n.º 4
0
Archivo: Test1.py Proyecto: irov/pybind
def go( i ):
    j1 = Test.test_function_1(5660 + i, 5454+ i+1)
    j2 = Test.test_function_2(43543 + i, 54534 + i * 2 )
    j3 = Test.test_function_3(435433 + i )
    
    def __cb(b):
        b.foo()
        b.min(1,2)
        
        Test.test_function_5(b)
        pass
    
    j4 = Test.test_function_4(__cb)
    pass
Ejemplo n.º 5
0
def _vectorExpr(instanceMethod):
    w = Test.currentWidget()
    name = '::' + str(w)
    if instanceMethod:
        w.expr(name + '+ 0.5')
    else:
        return Pmw.Blt.vector_expr(name + '* 2')
Ejemplo n.º 6
0
def get_similar():
    """API endpoint to search for similar houses to a given location
    :param lat,lon: Point on the map to search from of the search query
    :return: GeoJSON encoded collection of locations near the query Point
    """
    try:
        lat = float(request.args.get('lat', ''))
        lon = float(request.args.get('lon', ''))
    except:
        print "error"

    house = Test.generate_datum()
    house['lat'] = lat
    house['lon'] = lon
    house['dwelling_type'] = 'single-family'
    houses = house.get_similar(10)

    geo_houses = []

    for i in range(0,10):
        house = houses.iloc[i]
        feature = Feature(geometry=Point((house['lon'],house['lat'])))
        feature['dwelling_type'] = house['dwelling_type']
        feature['pool'] = house['pool']
        feature['list_price'] = house['list_price']
        geo_houses.append(feature)

    return Response(str(FeatureCollection(geo_houses)), mimetype="application/json")
Ejemplo n.º 7
0
def _vectorExpr(instanceMethod):
    w = Test.currentWidget()
    name = "::" + str(w)
    if instanceMethod:
        w.expr(name + "+ 0.5")
    else:
        return Pmw.Blt.vector_expr(name + "* 2")
Ejemplo n.º 8
0
 def test_move(self):
     self.assertEqual(Test.getObject(marv.x-1,marv.y),None)
     self.assertGreater(marv.movementLeft,0)
     res = marv.move(marv.x-1,marv.y)
     print (res)
     self.assertEqual([marv.x,marv.y],[1,3])
     self.assertEqual(marv.currentHealth,80-Test.healthPerMove)
def destroyManagedDomains():
    if len(_managedDomains) > 0:
        for m in _managedDomains:
            Test.traceCommand("xm destroy %s" % m)
            Test.traceCommand("xm delete %s" % m)
    if len(_VMuuids) > 0:
        for uuid in _VMuuids:
            Test.traceCommand("xm destroy %s" % uuid)
            Test.traceCommand("xm delete %s" % uuid)
Ejemplo n.º 10
0
def _addComponent():
    w = Test.currentWidget()
    label2 = w.createcomponent('label2',
            (), 'Mygroup',
            tkinter.Label, (w.interior(),),
            text = 'Temporary', background = 'yellow')
    label2.pack(fill = 'x')
    return label2.cget('text')
Ejemplo n.º 11
0
def _penNamesSorted(pattern = None):
    w = Test.currentWidget()
    if pattern is None:
        names = list(w.pen_names())
    else:
        names = list(w.pen_names(pattern))
    names.sort()
    return tuple(names)
Ejemplo n.º 12
0
def _vectorNames():
    name = '::' + str(Test.currentWidget())
    names = Pmw.Blt.vector_names()
    if name not in names:
        return names
    name2 = Pmw.Blt.vector_names(name)
    if name2 != (name,):
        return name2
    return None
Ejemplo n.º 13
0
def main():
  host = '127.0.0.1'
  port = 4000
  backlog = 10
  bufsize = 4096

  while true do:
      sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      with closing(sock):
        sock.bind((host, port))
        sock.listen(backlog)
        while True:
          conn, address = sock.accept()
          with closing(conn):
            msg = conn.recv(bufsize)
            insert_news.main(msg)
            conn.send(msg)
      return
Ejemplo n.º 14
0
 def test_move(self):
     self.marv = Test.Creature(35,2,3,1,120,40,20,4,2,2,2,7,31)
     Test.grid[2][3].append(self.marv)
     self.assertEqual(Test.getObject(self.marv.x-1,self.marv.y),None)
     self.assertGreater(self.marv.movementLeft,0)
     res = self.marv.move(self.marv.x-1,self.marv.y)
     self.assertTrue(res)
     self.assertEqual([self.marv.x,self.marv.y],[1,3])
     self.assertEqual(self.marv.currentHealth,40-Test.healthPerMove)
     Test.grid[1][3].remove(self.marv)
Ejemplo n.º 15
0
def _testYView(doBottom):
    w = Test.currentWidget()
    top, bottom = w.yview()
    if type(top) != type(0.0) or type(bottom) != type(0.0):
        return 'bad type ' + str(top) + ' ' + str(bottom)
    if doBottom:
        if bottom != 1.0:
            return 'bottom is ' + str(bottom)
    else:
        if top != 0.0:
            return 'top is ' + str(top)
Ejemplo n.º 16
0
def _checkGridInfo():
    w = Test.currentWidget()
    b8 = w.grid_slaves(column=0, row=3)[0]
    info = b8.grid_info()
    if info['in'] == w:
        rtn = {}
        for key, value in list(info.items()):
            if key != 'in':
                rtn[key] = value
        return rtn
    return 'BAD'
Ejemplo n.º 17
0
def _makeGridButtons():
    w = Test.currentWidget()
    b1 = tkinter.Button(w, text = 'Button 1')
    b2 = tkinter.Button(w, text = 'Button 2')
    b3 = tkinter.Button(w, text = 'Button 3')
    b4 = tkinter.Button(w, text = 'Button 4')
    b5 = tkinter.Button(w, text = 'Button 5')
    b6 = tkinter.Button(w, text = 'Button 6')
    b7 = tkinter.Button(w, text = 'Button 7')
    b8 = tkinter.Button(w, text = 'Button 8')

    b1.grid(column=0, row=0)
    b2.grid(column=1, row=0)
    b3.grid(column=2, row=0, ipadx=50, ipady=50, padx=50, pady=50, sticky='nsew')
    b4.grid(column=3, row=0)
    b5.grid(column=0, row=1)
    b6.grid(column=2, row=1, columnspan=2, rowspan=2, sticky='nsew')
    b7.grid(column=0, row=2)
    b8.grid(column=0, row=3, columnspan=4, padx=50, sticky='ew')
Ejemplo n.º 18
0
def _delVectorItem(index):
    w = Test.currentWidget()
    del w[index]
Ejemplo n.º 19
0
def _createMarkerButton():
    w = Test.currentWidget()
    button = tkinter.Button(w, text='This is\na button')
    w.marker_create('window', coords=(10, 200), window=button)
Ejemplo n.º 20
0
def _getVectorSlice(index1, index2):
    w = Test.currentWidget()
    return w[index1:index2]
Ejemplo n.º 21
0
def allTests(communicator):
    sys.stdout.write("testing equals() for Slice structures... ")
    sys.stdout.flush()

    #
    # Define some default values.
    #
    def_s2 = Test.S2(True, 98, 99, 100, 101, "string", (1, 2, 3),
                     Test.S1("name"))

    #
    # Compare default-constructed structures.
    #
    test(Test.S2() == Test.S2())

    #
    # Change one member at a time.
    #
    v = copy.copy(def_s2)
    test(v == def_s2)

    v = copy.copy(def_s2)
    v.bo = False
    test(v != def_s2)

    v = copy.copy(def_s2)
    v.by = v.by - 1
    test(v != def_s2)

    v = copy.copy(def_s2)
    v.sh = v.sh - 1
    test(v != def_s2)

    v = copy.copy(def_s2)
    v.i = v.i - 1
    test(v != def_s2)

    v = copy.copy(def_s2)
    v.l = v.l - 1
    test(v != def_s2)

    v = copy.copy(def_s2)
    v.str = ""
    test(v != def_s2)

    #
    # String member
    #
    v1 = copy.copy(def_s2)
    v1.str = "string"
    test(v1 == def_s2)

    v1 = copy.copy(def_s2)
    v2 = copy.copy(def_s2)
    v1.str = None
    test(v1 != v2)

    v1 = copy.copy(def_s2)
    v2 = copy.copy(def_s2)
    v2.str = None
    test(v1 != v2)

    v1 = copy.copy(def_s2)
    v2 = copy.copy(def_s2)
    v1.str = None
    v2.str = None
    test(v1 == v2)

    #
    # Sequence member
    #
    v1 = copy.copy(def_s2)
    v1.seq = copy.copy(def_s2.seq)
    test(v1 == def_s2)

    v1 = copy.copy(def_s2)
    v1.seq = ()
    test(v1 != def_s2)

    v1 = copy.copy(def_s2)
    v1.seq = (1, 2, 3)
    test(v1 == def_s2)

    v1 = copy.copy(def_s2)
    v2 = copy.copy(def_s2)
    v1.seq = None
    test(v1 != v2)

    v1 = copy.copy(def_s2)
    v2 = copy.copy(def_s2)
    v2.seq = None
    test(v1 != v2)

    #
    # Struct member
    #
    v1 = copy.copy(def_s2)
    v1.s = copy.copy(def_s2.s)
    test(v1 == def_s2)

    v1 = copy.copy(def_s2)
    v1.s = Test.S1("name")
    test(v1 == def_s2)

    v1 = copy.copy(def_s2)
    v1.s = Test.S1("noname")
    test(v1 != def_s2)

    v1 = copy.copy(def_s2)
    v2 = copy.copy(def_s2)
    v1.s = None
    test(v1 != v2)

    v1 = copy.copy(def_s2)
    v2 = copy.copy(def_s2)
    v2.s = None
    test(v1 != v2)

    #
    # Define some default values.
    #
    def_s3 = Test.S3(Test.C("name"), {"1": "2"},
                     communicator.stringToProxy("test"))

    #
    # Compare default-constructed structures.
    #
    test(Test.S3() == Test.S3())

    #
    # Change one member at a time.
    #
    v1 = copy.copy(def_s3)
    test(v1 == def_s3)

    v1.obj = None
    test(v1 != def_s3)

    v1.obj = Test.C("name")
    test(v1 != def_s3)

    v1 = copy.copy(def_s3)
    v1.sd = copy.copy(def_s3.sd)
    test(v1 == def_s3)

    v1.sd = None
    test(v1 != def_s3)

    v1.sd = {"1": "3"}
    test(v1 != def_s3)

    v1 = copy.copy(def_s3)
    v1.prx = None
    test(v1 != def_s3)

    v1.prx = communicator.stringToProxy("test")
    test(v1 == def_s3)

    v1.prx = communicator.stringToProxy("test2")
    test(v1 != def_s3)

    print("ok")
Ejemplo n.º 22
0
 def PBSUnknown2AsPreservedWithGraph(self, current=None):
     r = Test.PSUnknown2()
     r.pi = 5
     r.ps = "preserved"
     r.pb = r
     return Ice.Future.completed(r)
Ejemplo n.º 23
0
def _setbackground(name, colour):
    w = Test.currentWidget()
    w.pane(name).configure(background = colour)
Ejemplo n.º 24
0
print("Step 3: Copy/paste G12 and A3 ")
editingContext.Selection.SetRange([G12, A3])
atfEdit.Copy()
atfEdit.Paste()
G12Copy = circuitContainer.Elements[circuitContainer.Elements.Count - 2]
A3Copy = circuitContainer.Elements[circuitContainer.Elements.Count - 1]
G12Copy.Name = 'GC12'
A3Copy.Name = 'AC3'

#excise
print("Step 4: promote group G12 and A3 to template library")
hist.Begin("promote to template Library")
templateCmds.PromoteToTemplateLibrary([G12, A3])
templatingContext = templateCmds.TemplatingContext
Test.Equal(
    2, templatingContext.RootFolder.Templates.Count,
    "Varify two template items are created in the root folder of the template library"
)
hist.End()

print(
    "Step 5: make edges that connect from regular elements to referencing elements and vice versa"
)
hist.Begin("Making more edges")
edgesBefore = editingContext.CircuitContainer.Wires.Count
G12Ref = CircuitEditorUtil.GetElement(circuitContainer, 'G12')
A3Ref = CircuitEditorUtil.GetElement(circuitContainer, 'A3')
#edge from a regular group to a referencing element
G12Module = Adapters.Cast[Module](G12Copy.DomNode)
A3RefModule = Adapters.Cast[Module](A3Ref.DomNode)
#editingContext.Connect(G12Module, G12Module.Type.Outputs[0], A3RefModule, A3RefModule.Type.Inputs[0], None)
#edge from a regular group to a referencing group
Ejemplo n.º 25
0
 def oneElementCycle(self, current=None):
     b = Test.B()
     b.sb = "B1.sb"
     b.pb = b
     return b
Ejemplo n.º 26
0
 def SUnknownAsObject(self, current=None):
     su = Test.SUnknown()
     su.su = "SUnknown.su"
     return su
Ejemplo n.º 27
0
 def SBSUnknownDerivedAsSBaseCompact(self, current=None):
     sbsud = Test.SBSUnknownDerived()
     sbsud.sb = "SBSUnknownDerived.sb"
     sbsud.sbsud = "SBSUnknownDerived.sbsud"
     return sbsud
Ejemplo n.º 28
0
 def SBSKnownDerivedAsSBSKnownDerived(self, current=None):
     sbskd = Test.SBSKnownDerived()
     sbskd.sb = "SBSKnownDerived.sb"
     sbskd.sbskd = "SBSKnownDerived.sbskd"
     return sbskd
Ejemplo n.º 29
0
 def useForward(self, current=None):
     f = Test.Forward()
     f.h = Test.Hidden()
     f.h.f = f
     return f
Ejemplo n.º 30
0
def allTests(communicator):
    ref = "test:default -p 12010"
    base = communicator.stringToProxy(ref)
    test(base)

    custom = Test.CustomPrx.checkedCast(base)
    test(custom)

    byteList = [1, 2, 3, 4, 5]
    if sys.version_info[0] == 2:
        byteString = ''.join(map(chr, byteList))
    else:
        byteString = bytes(byteList)
    stringList = ['s1', 's2', 's3']

    sys.stdout.write("testing custom sequences... ")
    sys.stdout.flush()

    (r, b2) = custom.opByteString1(byteString)
    if sys.version_info[0] == 2:
        test(isinstance(r, str))
        test(isinstance(b2, str))
    else:
        test(isinstance(r, bytes))
        test(isinstance(b2, bytes))
    test(r == byteString)
    test(b2 == byteString)

    (r, b2) = custom.opByteString2(byteString)
    test(isinstance(r, tuple))
    test(isinstance(b2, list))
    for i in range(0, len(byteList)):
        test(r[i] == byteList[i])
        test(b2[i] == byteList[i])

    (r, b2) = custom.opByteList1(byteList)
    test(isinstance(r, list))
    test(isinstance(b2, list))
    for i in range(0, len(byteList)):
        test(r[i] == byteList[i])
        test(b2[i] == byteList[i])

    (r, b2) = custom.opByteList2(byteList)
    if sys.version_info[0] == 2:
        test(isinstance(r, str))
    else:
        test(isinstance(r, bytes))
    test(isinstance(b2, tuple))
    test(r == byteString)
    for i in range(0, len(byteList)):
        test(b2[i] == byteList[i])

    (r, b2) = custom.opStringList1(stringList)
    test(isinstance(r, list))
    test(isinstance(b2, list))
    test(r == stringList)
    test(b2 == stringList)

    (r, b2) = custom.opStringList2(stringList)
    test(isinstance(r, tuple))
    test(isinstance(b2, tuple))
    for i in range(0, len(stringList)):
        test(r[i] == stringList[i])
        test(b2[i] == stringList[i])

    (r, b2) = custom.opStringTuple1(stringList)
    test(isinstance(r, tuple))
    test(isinstance(b2, tuple))
    for i in range(0, len(stringList)):
        test(r[i] == stringList[i])
        test(b2[i] == stringList[i])

    (r, b2) = custom.opStringTuple2(stringList)
    test(isinstance(r, list))
    test(isinstance(b2, list))
    test(r == stringList)
    test(b2 == stringList)

    s = Test.S()
    s.b1 = byteList
    s.b2 = byteList
    s.b3 = byteList
    s.b4 = byteList
    s.s1 = stringList
    s.s2 = stringList
    s.s3 = stringList
    s.s4 = stringList
    custom.sendS(s)

    c = Test.C()
    c.b1 = byteList
    c.b2 = byteList
    c.b3 = byteList
    c.b4 = byteList
    c.s1 = stringList
    c.s2 = stringList
    c.s3 = stringList
    c.s4 = stringList
    custom.sendC(c)

    print("ok")

    return custom
Ejemplo n.º 31
0
def _populatePage(pageName):
    w = Test.currentWidget()
    page = w.page(pageName)
    text = tkinter.Text(page)
    text.pack()
    return w.pagenames()[w.index(pageName)]
Ejemplo n.º 32
0
 def opMStruct1(self, current):
     return Ice.Future.completed(
         Test.MyClass.OpMStruct1MarshaledResult(Test.Structure(), current))
Ejemplo n.º 33
0
#!/usr/bin/env python

import os
import re
import sys
import Tkinter

import Test
Test.initialise()

# Uncomment these to modify period between tests and how much output
# to print:
#Test.setdelay(1000)
#Test.setverbose(1)

# Ignore Tkinter test since it does not test any Pmw functionality
# (only Tkinter) and it fails under MS-Windows 95 (and it hasn't been
# kept up-to-date with changes to Tk.
ignoreTests = ('Tkinter_test.py',)

# Also ignore Blt test since it causes Blt 2.4z to core dump.
if Tkinter.TkVersion >= 8.4:
    ignoreTests = ignoreTests + ('Blt_test.py',)

allTestData = ()
files = os.listdir(os.curdir)
files.sort()

for file in files:
    if file not in ignoreTests and re.search('^.+_test.py$', file) is not None:
	test = file[:-3]
Ejemplo n.º 34
0
def allTests(communicator):
    obj = communicator.stringToProxy("Test:default -p 12010")
    t = Test.TestIntfPrx.checkedCast(obj)

    sys.stdout.write("base as Object... ")
    sys.stdout.flush()
    o = None
    try:
        o = t.SBaseAsObject()
        test(o)
        test(o.ice_id() == "::Test::SBase")
    except Ice.Exception:
        test(False)
    sb = o
    test(isinstance(sb, Test.SBase))
    test(sb)
    test(sb.sb == "SBase.sb")
    print("ok")

    sys.stdout.write("base as Object (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_SBaseAsObject(cb.response_SBaseAsObject, cb.exception)
    cb.check()
    print("ok")

    sys.stdout.write("base as base... ")
    sys.stdout.flush()
    try:
        sb = t.SBaseAsSBase()
        test(sb.sb == "SBase.sb")
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("base as base (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_SBaseAsSBase(cb.response_SBaseAsSBase, cb.exception)
    cb.check()
    print("ok")

    sys.stdout.write("base with known derived as base... ")
    sys.stdout.flush()
    try:
        sb = t.SBSKnownDerivedAsSBase()
        test(sb.sb == "SBSKnownDerived.sb")
    except Ice.Exception:
        test(False)
    sbskd = sb
    test(isinstance(sbskd, Test.SBSKnownDerived))
    test(sbskd)
    test(sbskd.sbskd == "SBSKnownDerived.sbskd")
    print("ok")

    sys.stdout.write("base with known derived as base (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_SBSKnownDerivedAsSBase(cb.response_SBSKnownDerivedAsSBase, cb.exception)
    cb.check()
    print("ok")

    sys.stdout.write("base with known derived as known derived... ")
    sys.stdout.flush()
    try:
        sbskd = t.SBSKnownDerivedAsSBSKnownDerived()
        test(sbskd.sbskd == "SBSKnownDerived.sbskd")
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("base with known derived as known derived (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_SBSKnownDerivedAsSBSKnownDerived(cb.response_SBSKnownDerivedAsSBSKnownDerived, cb.exception)
    cb.check()
    print("ok")

    sys.stdout.write("base with unknown derived as base... ")
    sys.stdout.flush()
    try:
        sb = t.SBSUnknownDerivedAsSBase()
        test(sb.sb == "SBSUnknownDerived.sb")
    except Ice.Exception:
        test(False)
    if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
        try:
            #
            # This test succeeds for the 1.0 encoding.
            #
            sb = t.SBSUnknownDerivedAsSBaseCompact()
            test(sb.sb == "SBSUnknownDerived.sb")
        except Ice.OperationNotExistException:
            pass
        except:
            test(False)
    else:
        try:
            #
            # This test fails when using the compact format because the instance cannot
            # be sliced to a known type.
            #
            sb = t.SBSUnknownDerivedAsSBaseCompact()
            test(False)
        except Ice.OperationNotExistException:
            pass
        except Ice.NoValueFactoryException:
            # Expected.
            pass
        except:
            test(False)
    print("ok")

    sys.stdout.write("base with unknown derived as base (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_SBSUnknownDerivedAsSBase(cb.response_SBSUnknownDerivedAsSBase, cb.exception)
    cb.check()
    if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
        #
        # This test succeeds for the 1.0 encoding.
        #
        cb = Callback()
        t.begin_SBSUnknownDerivedAsSBaseCompact(cb.response_SBSUnknownDerivedAsSBase, cb.exception)
        cb.check()
    else:
        #
        # This test fails when using the compact format because the instance cannot
        # be sliced to a known type.
        #
        cb = Callback()
        t.begin_SBSUnknownDerivedAsSBaseCompact(cb.response_SBSUnknownDerivedAsSBaseCompact,
                                                cb.exception_SBSUnknownDerivedAsSBaseCompact)
        cb.check()
    print("ok")

    sys.stdout.write("unknown with Object as Object... ")
    sys.stdout.flush()
    try:
        o = t.SUnknownAsObject()
        test(t.ice_getEncodingVersion() != Ice.Encoding_1_0)
        test(isinstance(o, Ice.UnknownSlicedObject))
        test(o.unknownTypeId == "::Test::SUnknown")
        t.checkSUnknown(o)
    except Ice.NoValueFactoryException:
        test(t.ice_getEncodingVersion() == Ice.Encoding_1_0)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("unknown with Object as Object (AMI)... ")
    sys.stdout.flush()
    try:
        cb = Callback()
        if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
            t.begin_SUnknownAsObject(cb.response_SUnknownAsObject10, cb.exception_SUnknownAsObject10)
        else:
            t.begin_SUnknownAsObject(cb.response_SUnknownAsObject11, cb.exception_SUnknownAsObject11)
        cb.check()
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("one-element cycle... ")
    sys.stdout.flush()
    try:
        b = t.oneElementCycle()
        test(b)
        test(b.ice_id() == "::Test::B")
        test(b.sb == "B1.sb")
        test(b.pb == b)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("one-element cycle (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_oneElementCycle(cb.response_oneElementCycle, cb.exception)
    cb.check()
    print("ok")

    sys.stdout.write("two-element cycle... ")
    sys.stdout.flush()
    try:
        b1 = t.twoElementCycle()
        test(b1)
        test(b1.ice_id() == "::Test::B")
        test(b1.sb == "B1.sb")

        b2 = b1.pb
        test(b2)
        test(b2.ice_id() == "::Test::B")
        test(b2.sb == "B2.sb")
        test(b2.pb == b1)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("two-element cycle (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_twoElementCycle(cb.response_twoElementCycle, cb.exception)
    cb.check()
    print("ok")

    sys.stdout.write("known derived pointer slicing as base... ")
    sys.stdout.flush()
    try:
        b1 = t.D1AsB()
        test(b1)
        test(b1.ice_id() == "::Test::D1")
        test(b1.sb == "D1.sb")
        test(b1.pb)
        test(b1.pb != b1)
        d1 = b1
        test(isinstance(d1, Test.D1))
        test(d1.sd1 == "D1.sd1")
        test(d1.pd1)
        test(d1.pd1 != b1)
        test(b1.pb == d1.pd1)

        b2 = b1.pb
        test(b2)
        test(b2.pb == b1)
        test(b2.sb == "D2.sb")
        test(b2.ice_id() == "::Test::B")
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("known derived pointer slicing as base (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_D1AsB(cb.response_D1AsB, cb.exception)
    cb.check()
    print("ok")

    sys.stdout.write("known derived pointer slicing as derived... ")
    sys.stdout.flush()
    try:
        d1 = t.D1AsD1()
        test(d1)
        test(d1.ice_id() == "::Test::D1")
        test(d1.sb == "D1.sb")
        test(d1.pb)
        test(d1.pb != d1)

        b2 = d1.pb
        test(b2)
        test(b2.ice_id() == "::Test::B")
        test(b2.sb == "D2.sb")
        test(b2.pb == d1)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("known derived pointer slicing as derived (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_D1AsD1(cb.response_D1AsD1, cb.exception)
    cb.check()
    print("ok")

    sys.stdout.write("unknown derived pointer slicing as base... ")
    sys.stdout.flush()
    try:
        b2 = t.D2AsB()
        test(b2)
        test(b2.ice_id() == "::Test::B")
        test(b2.sb == "D2.sb")
        test(b2.pb)
        test(b2.pb != b2)

        b1 = b2.pb
        test(b1)
        test(b1.ice_id() == "::Test::D1")
        test(b1.sb == "D1.sb")
        test(b1.pb == b2)
        d1 = b1
        test(isinstance(d1, Test.D1))
        test(d1.sd1 == "D1.sd1")
        test(d1.pd1 == b2)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("unknown derived pointer slicing as base (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_D2AsB(cb.response_D2AsB, cb.exception)
    cb.check()
    print("ok")

    sys.stdout.write("param ptr slicing with known first... ")
    sys.stdout.flush()
    try:
        b1, b2 = t.paramTest1()

        test(b1)
        test(b1.ice_id() == "::Test::D1")
        test(b1.sb == "D1.sb")
        test(b1.pb == b2)
        d1 = b1
        test(isinstance(d1, Test.D1))
        test(d1.sd1 == "D1.sd1")
        test(d1.pd1 == b2)

        test(b2)
        test(b2.ice_id() == "::Test::B")        # No factory, must be sliced
        test(b2.sb == "D2.sb")
        test(b2.pb == b1)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("param ptr slicing with known first (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_paramTest1(cb.response_paramTest1, cb.exception)
    cb.check()
    print("ok")

    sys.stdout.write("param ptr slicing with unknown first... ")
    sys.stdout.flush()
    try:
        b2, b1 = t.paramTest2()

        test(b1)
        test(b1.ice_id() == "::Test::D1")
        test(b1.sb == "D1.sb")
        test(b1.pb == b2)
        d1 = b1
        test(isinstance(d1, Test.D1))
        test(d1.sd1 == "D1.sd1")
        test(d1.pd1 == b2)

        test(b2)
        test(b2.ice_id() == "::Test::B")        # No factory, must be sliced
        test(b2.sb == "D2.sb")
        test(b2.pb == b1)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("return value identity with known first... ")
    sys.stdout.flush()
    try:
        r, p1, p2 = t.returnTest1()
        test(r == p1)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("return value identity with known first (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_returnTest1(cb.response_returnTest1, cb.exception)
    cb.check()
    print("ok")

    sys.stdout.write("return value identity with unknown first... ")
    sys.stdout.flush()
    try:
        r, p1, p2 = t.returnTest2()
        test(r == p1)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("return value identity with unknown first (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_returnTest2(cb.response_returnTest2, cb.exception)
    cb.check()
    print("ok")

    sys.stdout.write("return value identity for input params known first... ")
    sys.stdout.flush()
    try:
        d1 = Test.D1()
        d1.sb = "D1.sb"
        d1.sd1 = "D1.sd1"
        d3 = Test.D3()
        d3.pb = d1
        d3.sb = "D3.sb"
        d3.sd3 = "D3.sd3"
        d3.pd3 = d1
        d1.pb = d3
        d1.pd1 = d3

        b1 = t.returnTest3(d1, d3)

        test(b1)
        test(b1.sb == "D1.sb")
        test(b1.ice_id() == "::Test::D1")
        p1 = b1
        test(isinstance(p1, Test.D1))
        test(p1.sd1 == "D1.sd1")
        test(p1.pd1 == b1.pb)

        b2 = b1.pb
        test(b2)
        test(b2.sb == "D3.sb")
        test(b2.ice_id() == "::Test::B")        # Sliced by server
        test(b2.pb == b1)
        p3 = b2
        test(not isinstance(p3, Test.D3))

        test(b1 != d1)
        test(b1 != d3)
        test(b2 != d1)
        test(b2 != d3)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("return value identity for input params known first (AMI)... ")
    sys.stdout.flush()
    try:
        d1 = Test.D1()
        d1.sb = "D1.sb"
        d1.sd1 = "D1.sd1"
        d3 = Test.D3()
        d3.pb = d1
        d3.sb = "D3.sb"
        d3.sd3 = "D3.sd3"
        d3.pd3 = d1
        d1.pb = d3
        d1.pd1 = d3

        cb = Callback()
        t.begin_returnTest3(d1, d3, cb.response_returnTest3, cb.exception)
        cb.check()
        b1 = cb.r

        test(b1)
        test(b1.sb == "D1.sb")
        test(b1.ice_id() == "::Test::D1")
        p1 = b1
        test(isinstance(p1, Test.D1))
        test(p1.sd1 == "D1.sd1")
        test(p1.pd1 == b1.pb)

        b2 = b1.pb
        test(b2)
        test(b2.sb == "D3.sb")
        test(b2.ice_id() == "::Test::B")        # Sliced by server
        test(b2.pb == b1)
        p3 = b2
        test(not isinstance(p3, Test.D3))

        test(b1 != d1)
        test(b1 != d3)
        test(b2 != d1)
        test(b2 != d3)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("return value identity for input params unknown first... ")
    sys.stdout.flush()
    try:
        d1 = Test.D1()
        d1.sb = "D1.sb"
        d1.sd1 = "D1.sd1"
        d3 = Test.D3()
        d3.pb = d1
        d3.sb = "D3.sb"
        d3.sd3 = "D3.sd3"
        d3.pd3 = d1
        d1.pb = d3
        d1.pd1 = d3

        b1 = t.returnTest3(d3, d1)

        test(b1)
        test(b1.sb == "D3.sb")
        test(b1.ice_id() == "::Test::B")        # Sliced by server
        p1 = b1
        test(not isinstance(p1, Test.D3))

        b2 = b1.pb
        test(b2)
        test(b2.sb == "D1.sb")
        test(b2.ice_id() == "::Test::D1")
        test(b2.pb == b1)
        p3 = b2
        test(isinstance(p3, Test.D1))
        test(p3.sd1 == "D1.sd1")
        test(p3.pd1 == b1)

        test(b1 != d1)
        test(b1 != d3)
        test(b2 != d1)
        test(b2 != d3)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("return value identity for input params unknown first (AMI)... ")
    sys.stdout.flush()
    try:
        d1 = Test.D1()
        d1.sb = "D1.sb"
        d1.sd1 = "D1.sd1"
        d3 = Test.D3()
        d3.pb = d1
        d3.sb = "D3.sb"
        d3.sd3 = "D3.sd3"
        d3.pd3 = d1
        d1.pb = d3
        d1.pd1 = d3

        cb = Callback()
        t.begin_returnTest3(d3, d1, cb.response_returnTest3, cb.exception)
        cb.check()
        b1 = cb.r

        test(b1)
        test(b1.sb == "D3.sb")
        test(b1.ice_id() == "::Test::B")        # Sliced by server
        p1 = b1
        test(not isinstance(p1, Test.D3))

        b2 = b1.pb
        test(b2)
        test(b2.sb == "D1.sb")
        test(b2.ice_id() == "::Test::D1")
        test(b2.pb == b1)
        p3 = b2
        test(isinstance(p3, Test.D1))
        test(p3.sd1 == "D1.sd1")
        test(p3.pd1 == b1)

        test(b1 != d1)
        test(b1 != d3)
        test(b2 != d1)
        test(b2 != d3)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("remainder unmarshaling (3 instances)... ")
    sys.stdout.flush()
    try:
        ret, p1, p2 = t.paramTest3()

        test(p1)
        test(p1.sb == "D2.sb (p1 1)")
        test(p1.pb == None)
        test(p1.ice_id() == "::Test::B")

        test(p2)
        test(p2.sb == "D2.sb (p2 1)")
        test(p2.pb == None)
        test(p2.ice_id() == "::Test::B")

        test(ret)
        test(ret.sb == "D1.sb (p2 2)")
        test(ret.pb == None)
        test(ret.ice_id() == "::Test::D1")
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("remainder unmarshaling (3 instances) (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_paramTest3(cb.response_paramTest3, cb.exception)
    cb.check()
    print("ok")

    sys.stdout.write("remainder unmarshaling (4 instances)... ")
    sys.stdout.flush()
    try:
        ret, b = t.paramTest4()

        test(b)
        test(b.sb == "D4.sb (1)")
        test(b.pb == None)
        test(b.ice_id() == "::Test::B")

        test(ret)
        test(ret.sb == "B.sb (2)")
        test(ret.pb == None)
        test(ret.ice_id() == "::Test::B")
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("remainder unmarshaling (4 instances) (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_paramTest4(cb.response_paramTest4, cb.exception)
    cb.check()
    print("ok")

    sys.stdout.write("param ptr slicing, instance marshaled in unknown derived as base... ")
    sys.stdout.flush()
    try:
        b1 = Test.B()
        b1.sb = "B.sb(1)"
        b1.pb = b1

        d3 = Test.D3()
        d3.sb = "D3.sb"
        d3.pb = d3
        d3.sd3 = "D3.sd3"
        d3.pd3 = b1

        b2 = Test.B()
        b2.sb = "B.sb(2)"
        b2.pb = b1

        r = t.returnTest3(d3, b2)

        test(r)
        test(r.ice_id() == "::Test::B")
        test(r.sb == "D3.sb")
        test(r.pb == r)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("param ptr slicing, instance marshaled in unknown derived as base (AMI)... ")
    sys.stdout.flush()
    try:
        b1 = Test.B()
        b1.sb = "B.sb(1)"
        b1.pb = b1

        d3 = Test.D3()
        d3.sb = "D3.sb"
        d3.pb = d3
        d3.sd3 = "D3.sd3"
        d3.pd3 = b1

        b2 = Test.B()
        b2.sb = "B.sb(2)"
        b2.pb = b1

        cb = Callback()
        t.begin_returnTest3(d3, b2, cb.response_returnTest3, cb.exception)
        cb.check()
        r = cb.r

        test(r)
        test(r.ice_id() == "::Test::B")
        test(r.sb == "D3.sb")
        test(r.pb == r)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("param ptr slicing, instance marshaled in unknown derived as derived... ")
    sys.stdout.flush()
    try:
        d11 = Test.D1()
        d11.sb = "D1.sb(1)"
        d11.pb = d11
        d11.sd1 = "D1.sd1(1)"
        d11.pd1 = None

        d3 = Test.D3()
        d3.sb = "D3.sb"
        d3.pb = d3
        d3.sd3 = "D3.sd3"
        d3.pd3 = d11

        d12 = Test.D1()
        d12.sb = "D1.sb(2)"
        d12.pb = d12
        d12.sd1 = "D1.sd1(2)"
        d12.pd1 = d11

        r = t.returnTest3(d3, d12)
        test(r)
        test(r.ice_id() == "::Test::B")
        test(r.sb == "D3.sb")
        test(r.pb == r)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("param ptr slicing, instance marshaled in unknown derived as derived (AMI)... ")
    sys.stdout.flush()
    try:
        d11 = Test.D1()
        d11.sb = "D1.sb(1)"
        d11.pb = d11
        d11.sd1 = "D1.sd1(1)"
        d11.pd1 = None

        d3 = Test.D3()
        d3.sb = "D3.sb"
        d3.pb = d3
        d3.sd3 = "D3.sd3"
        d3.pd3 = d11

        d12 = Test.D1()
        d12.sb = "D1.sb(2)"
        d12.pb = d12
        d12.sd1 = "D1.sd1(2)"
        d12.pd1 = d11

        cb = Callback()
        t.begin_returnTest3(d3, d12, cb.response_returnTest3, cb.exception)
        cb.check()
        r = cb.r

        test(r)
        test(r.ice_id() == "::Test::B")
        test(r.sb == "D3.sb")
        test(r.pb == r)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("sequence slicing... ")
    sys.stdout.flush()
    try:
        ss = Test.SS3()
        ss1b = Test.B()
        ss1b.sb = "B.sb"
        ss1b.pb = ss1b

        ss1d1 = Test.D1()
        ss1d1.sb = "D1.sb"
        ss1d1.sd1 = "D1.sd1"
        ss1d1.pb = ss1b

        ss1d3 = Test.D3()
        ss1d3.sb = "D3.sb"
        ss1d3.sd3 = "D3.sd3"
        ss1d3.pb = ss1b

        ss2b = Test.B()
        ss2b.sb = "B.sb"
        ss2b.pb = ss1b

        ss2d1 = Test.D1()
        ss2d1.sb = "D1.sb"
        ss2d1.sd1 = "D1.sd1"
        ss2d1.pb = ss2b

        ss2d3 = Test.D3()
        ss2d3.sb = "D3.sb"
        ss2d3.sd3 = "D3.sd3"
        ss2d3.pb = ss2b

        ss1d1.pd1 = ss2b
        ss1d3.pd3 = ss2d1

        ss2d1.pd1 = ss1d3
        ss2d3.pd3 = ss1d1

        ss1 = Test.SS1()
        ss1.s = (ss1b, ss1d1, ss1d3)

        ss2 = Test.SS2()
        ss2.s = (ss2b, ss2d1, ss2d3)

        ss = t.sequenceTest(ss1, ss2)

        test(ss.c1)
        ss1b = ss.c1.s[0]
        ss1d1 = ss.c1.s[1]
        test(ss.c2)
        ss1d3 = ss.c1.s[2]

        test(ss.c2)
        ss2b = ss.c2.s[0]
        ss2d1 = ss.c2.s[1]
        ss2d3 = ss.c2.s[2]

        test(ss1b.pb == ss1b)
        test(ss1d1.pb == ss1b)
        test(ss1d3.pb == ss1b)

        test(ss2b.pb == ss1b)
        test(ss2d1.pb == ss2b)
        test(ss2d3.pb == ss2b)

        test(ss1b.ice_id() == "::Test::B")
        test(ss1d1.ice_id() == "::Test::D1")
        test(ss1d3.ice_id() == "::Test::B")

        test(ss2b.ice_id() == "::Test::B")
        test(ss2d1.ice_id() == "::Test::D1")
        test(ss2d3.ice_id() == "::Test::B")
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("sequence slicing (AMI)... ")
    sys.stdout.flush()
    try:
        ss = Test.SS3()
        ss1b = Test.B()
        ss1b.sb = "B.sb"
        ss1b.pb = ss1b

        ss1d1 = Test.D1()
        ss1d1.sb = "D1.sb"
        ss1d1.sd1 = "D1.sd1"
        ss1d1.pb = ss1b

        ss1d3 = Test.D3()
        ss1d3.sb = "D3.sb"
        ss1d3.sd3 = "D3.sd3"
        ss1d3.pb = ss1b

        ss2b = Test.B()
        ss2b.sb = "B.sb"
        ss2b.pb = ss1b

        ss2d1 = Test.D1()
        ss2d1.sb = "D1.sb"
        ss2d1.sd1 = "D1.sd1"
        ss2d1.pb = ss2b

        ss2d3 = Test.D3()
        ss2d3.sb = "D3.sb"
        ss2d3.sd3 = "D3.sd3"
        ss2d3.pb = ss2b

        ss1d1.pd1 = ss2b
        ss1d3.pd3 = ss2d1

        ss2d1.pd1 = ss1d3
        ss2d3.pd3 = ss1d1

        ss1 = Test.SS1()
        ss1.s = (ss1b, ss1d1, ss1d3)

        ss2 = Test.SS2()
        ss2.s = (ss2b, ss2d1, ss2d3)

        cb = Callback()
        t.begin_sequenceTest(ss1, ss2, cb.response_sequenceTest, cb.exception)
        cb.check()
        ss = cb.r

        test(ss.c1)
        ss1b = ss.c1.s[0]
        ss1d1 = ss.c1.s[1]
        test(ss.c2)
        ss1d3 = ss.c1.s[2]

        test(ss.c2)
        ss2b = ss.c2.s[0]
        ss2d1 = ss.c2.s[1]
        ss2d3 = ss.c2.s[2]

        test(ss1b.pb == ss1b)
        test(ss1d1.pb == ss1b)
        test(ss1d3.pb == ss1b)

        test(ss2b.pb == ss1b)
        test(ss2d1.pb == ss2b)
        test(ss2d3.pb == ss2b)

        test(ss1b.ice_id() == "::Test::B")
        test(ss1d1.ice_id() == "::Test::D1")
        test(ss1d3.ice_id() == "::Test::B")

        test(ss2b.ice_id() == "::Test::B")
        test(ss2d1.ice_id() == "::Test::D1")
        test(ss2d3.ice_id() == "::Test::B")
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("dictionary slicing... ")
    sys.stdout.flush()
    try:
        bin = {}
        for i in range(0, 10):
            d1 = Test.D1()
            s = "D1." + str(i)
            d1.sb = s
            d1.pb = d1
            d1.sd1 = s
            d1.pd1 = None
            bin[i] = d1

        r, bout = t.dictionaryTest(bin)

        test(len(bout) == 10)
        for i in range(0, 10):
            b = bout[i * 10]
            test(b)
            s = "D1." + str(i)
            test(b.sb == s)
            test(b.pb)
            test(b.pb != b)
            test(b.pb.sb == s)
            test(b.pb.pb == b.pb)

        test(len(r) == 10)
        for i in range(0, 10):
            b = r[i * 20]
            test(b)
            s = "D1." + str(i * 20)
            test(b.sb == s)
            if i == 0:
                test(b.pb == None)
            else:
                test(b.pb == r[(i - 1) * 20])
            d1 = b
            test(isinstance(d1, Test.D1))
            test(d1.sd1 == s)
            test(d1.pd1 == d1)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("dictionary slicing (AMI)... ")
    sys.stdout.flush()
    try:
        bin = {}
        for i in range(0, 10):
            d1 = Test.D1()
            s = "D1." + str(i)
            d1.sb = s
            d1.pb = d1
            d1.sd1 = s
            d1.pd1 = None
            bin[i] = d1

        cb = Callback()
        t.begin_dictionaryTest(bin, cb.response_dictionaryTest, cb.exception)
        cb.check()
        bout = cb.bout
        r = cb.r

        test(len(bout) == 10)
        for i in range(0, 10):
            b = bout[i * 10]
            test(b)
            s = "D1." + str(i)
            test(b.sb == s)
            test(b.pb)
            test(b.pb != b)
            test(b.pb.sb == s)
            test(b.pb.pb == b.pb)

        test(len(r) == 10)
        for i in range(0, 10):
            b = r[i * 20]
            test(b)
            s = "D1." + str(i * 20)
            test(b.sb == s)
            if i == 0:
                test(b.pb == None)
            else:
                test(b.pb == r[(i - 1) * 20])
            d1 = b
            test(isinstance(d1, Test.D1))
            test(d1.sd1 == s)
            test(d1.pd1 == d1)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("base exception thrown as base exception... ")
    sys.stdout.flush()
    try:
        t.throwBaseAsBase()
        test(False)
    except Test.BaseException as e:
        test(e.ice_name() == "Test::BaseException")
        test(e.sbe == "sbe")
        test(e.pb)
        test(e.pb.sb == "sb")
        test(e.pb.pb == e.pb)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("base exception thrown as base exception (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_throwBaseAsBase(cb.response, cb.exception_throwBaseAsBase)
    cb.check()
    print("ok")

    sys.stdout.write("derived exception thrown as base exception... ")
    sys.stdout.flush()
    try:
        t.throwDerivedAsBase()
        test(False)
    except Test.DerivedException as e:
        test(e.ice_name() == "Test::DerivedException")
        test(e.sbe == "sbe")
        test(e.pb)
        test(e.pb.sb == "sb1")
        test(e.pb.pb == e.pb)
        test(e.sde == "sde1")
        test(e.pd1)
        test(e.pd1.sb == "sb2")
        test(e.pd1.pb == e.pd1)
        test(e.pd1.sd1 == "sd2")
        test(e.pd1.pd1 == e.pd1)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("derived exception thrown as base exception (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_throwDerivedAsBase(cb.response, cb.exception_throwDerivedAsBase)
    cb.check()
    print("ok")

    sys.stdout.write("derived exception thrown as derived exception... ")
    sys.stdout.flush()
    try:
        t.throwDerivedAsDerived()
        test(False)
    except Test.DerivedException as e:
        test(e.ice_name() == "Test::DerivedException")
        test(e.sbe == "sbe")
        test(e.pb)
        test(e.pb.sb == "sb1")
        test(e.pb.pb == e.pb)
        test(e.sde == "sde1")
        test(e.pd1)
        test(e.pd1.sb == "sb2")
        test(e.pd1.pb == e.pd1)
        test(e.pd1.sd1 == "sd2")
        test(e.pd1.pd1 == e.pd1)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("derived exception thrown as derived exception (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_throwDerivedAsDerived(cb.response, cb.exception_throwDerivedAsDerived)
    cb.check()
    print("ok")

    sys.stdout.write("unknown derived exception thrown as base exception... ")
    sys.stdout.flush()
    try:
        t.throwUnknownDerivedAsBase()
        test(False)
    except Test.BaseException as e:
        test(e.ice_name() == "Test::BaseException")
        test(e.sbe == "sbe")
        test(e.pb)
        test(e.pb.sb == "sb d2")
        test(e.pb.pb == e.pb)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("unknown derived exception thrown as base exception (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_throwUnknownDerivedAsBase(cb.response, cb.exception_throwUnknownDerivedAsBase)
    cb.check()
    print("ok")

    sys.stdout.write("forward-declared class... ")
    sys.stdout.flush()
    try:
        f = t.useForward()
        test(f)
    except Ice.Exception:
        test(False)
    print("ok")

    sys.stdout.write("forward-declared class (AMI)... ")
    sys.stdout.flush()
    cb = Callback()
    t.begin_useForward(cb.response_useForward, cb.exception)
    cb.check()
    print("ok")

    sys.stdout.write("preserved classes... ")
    sys.stdout.flush()

    try:
        #
        # Server knows the most-derived class PDerived.
        #
        pd = Test.PDerived()
        pd.pi = 3
        pd.ps = "preserved"
        pd.pb = pd

        r = t.exchangePBase(pd)
        test(isinstance(r, Test.PDerived))
        test(r.pi == 3)
        test(r.ps == "preserved")
        test(r.pb == r)

        #
        # Server only knows the base (non-preserved) type, so the object is sliced.
        #
        pu = Test.PCUnknown()
        pu.pi = 3
        pu.pu = "preserved"

        r = t.exchangePBase(pu)
        test(not isinstance(r, Test.PCUnknown))
        test(r.pi == 3)

        #
        # Server only knows the intermediate type Preserved. The object will be sliced to
        # Preserved for the 1.0 encoding; otherwise it should be returned intact.
        #
        pcd = Test.PCDerived()
        pcd.pi = 3
        pcd.pbs = [ pcd ]

        r = t.exchangePBase(pcd)
        if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
            test(not isinstance(r, Test.PCDerived))
            test(r.pi == 3)
        else:
            test(isinstance(r, Test.PCDerived))
            test(r.pi == 3)
            test(r.pbs[0] == r)

        #
        # Server only knows the intermediate type CompactPDerived. The object will be sliced to
        # CompactPDerived for the 1.0 encoding; otherwise it should be returned intact.
        #
        pcd = Test.CompactPCDerived()
        pcd.pi = 3
        pcd.pbs = [ pcd ]

        r = t.exchangePBase(pcd)
        if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
            test(not isinstance(r, Test.CompactPCDerived))
            test(r.pi == 3)
        else:
            test(isinstance(r, Test.CompactPCDerived))
            test(r.pi == 3)
            test(r.pbs[0] == r)

        #
        # Send an object that will have multiple preserved slices in the server.
        # The object will be sliced to Preserved for the 1.0 encoding.
        #
        pcd = Test.PCDerived3()
        pcd.pi = 3
        #
        # Sending more than 254 objects exercises the encoding for object ids.
        #
        pcd.pbs = []
        for i in range(0, 300):
            p2 = Test.PCDerived2()
            p2.pi = i
            p2.pbs = [ None ] # Nil reference. This slice should not have an indirection table.
            p2.pcd2 = i
            pcd.pbs.append(p2)
        pcd.pcd2 = pcd.pi
        pcd.pcd3 = pcd.pbs[10]

        r = t.exchangePBase(pcd)
        if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
            test(not isinstance(r, Test.PCDerived3))
            test(isinstance(r, Test.Preserved))
            test(r.pi == 3)
        else:
            test(isinstance(r, Test.PCDerived3))
            test(r.pi == 3)
            for i in range(0, 300):
                p2 = r.pbs[i]
                test(isinstance(p2, Test.PCDerived2))
                test(p2.pi == i)
                test(len(p2.pbs) == 1)
                test(not p2.pbs[0])
                test(p2.pcd2 == i)
            test(r.pcd2 == r.pi)
            test(r.pcd3 == r.pbs[10])

        #
        # Obtain an object with preserved slices and send it back to the server.
        # The preserved slices should be excluded for the 1.0 encoding, otherwise
        # they should be included.
        #
        p = t.PBSUnknownAsPreserved()
        t.checkPBSUnknown(p)
        if t.ice_getEncodingVersion() != Ice.Encoding_1_0:
            t.ice_encodingVersion(Ice.Encoding_1_0).checkPBSUnknown(p)
    except Ice.OperationNotExistException:
        pass

    print("ok")

    sys.stdout.write("preserved classes (AMI)... ")
    sys.stdout.flush()

    #
    # Server knows the most-derived class PDerived.
    #
    pd = Test.PDerived()
    pd.pi = 3
    pd.ps = "preserved"
    pd.pb = pd

    cb = Callback()
    t.begin_exchangePBase(pd, cb.response_preserved1, cb.exception)
    cb.check()

    #
    # Server only knows the base (non-preserved) type, so the object is sliced.
    #
    pu = Test.PCUnknown()
    pu.pi = 3
    pu.pu = "preserved"

    cb = Callback()
    t.begin_exchangePBase(pu, cb.response_preserved2, cb.exception)
    cb.check()

    #
    # Server only knows the intermediate type Preserved. The object will be sliced to
    # Preserved for the 1.0 encoding; otherwise it should be returned intact.
    #
    pcd = Test.PCDerived()
    pcd.pi = 3
    pcd.pbs = [ pcd ]

    cb = Callback()
    if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
        t.begin_exchangePBase(pcd, cb.response_preserved3, cb.exception)
    else:
        t.begin_exchangePBase(pcd, cb.response_preserved4, cb.exception)
    cb.check()

    #
    # Server only knows the intermediate type CompactPDerived. The object will be sliced to
    # CompactPDerived for the 1.0 encoding; otherwise it should be returned intact.
    #
    pcd = Test.CompactPCDerived()
    pcd.pi = 3
    pcd.pbs = [ pcd ]

    cb = Callback()
    if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
        t.begin_exchangePBase(pcd, cb.response_compactPreserved1, cb.exception)
    else:
        t.begin_exchangePBase(pcd, cb.response_compactPreserved2, cb.exception)
    cb.check()

    #
    # Send an object that will have multiple preserved slices in the server.
    # The object will be sliced to Preserved for the 1.0 encoding.
    #
    pcd = Test.PCDerived3()
    pcd.pi = 3
    #
    # Sending more than 254 objects exercises the encoding for object ids.
    #
    pcd.pbs = []
    for i in range(0, 300):
        p2 = Test.PCDerived2()
        p2.pi = i
        p2.pbs = [ None ] # Nil reference. This slice should not have an indirection table.
        p2.pcd2 = i
        pcd.pbs.append(p2)
    pcd.pcd2 = pcd.pi
    pcd.pcd3 = pcd.pbs[10]

    cb = Callback()
    if t.ice_getEncodingVersion() == Ice.Encoding_1_0:
        t.begin_exchangePBase(pcd, cb.response_preserved3, cb.exception)
    else:
        t.begin_exchangePBase(pcd, cb.response_preserved5, cb.exception)
    cb.check()

    print("ok")

    sys.stdout.write("garbage collection of preserved classes... ")
    sys.stdout.flush()
    try:
        #
        # Register a factory in order to substitute our own subclass of
        # UCNode. This provides an easy way to determine how many
        # unmarshaled instances currently exist.
        #
        communicator.addValueFactory(NodeFactoryI, Test.PNode.ice_staticId())

        #
        # Relay a graph through the server. This test uses a preserved class
        # with a class member.
        #
        c = Test.PNode()
        c.next = Test.PNode()
        c.next.next = Test.PNode()
        c.next.next.next = c    # Create a cyclic graph.

        test(PNodeI.counter == 0)
        n = t.exchangePNode(c)
        test(PNodeI.counter == 3)
        test(n.next != None)
        test(n.next != n.next.next)
        test(n.next.next != n.next.next.next)
        test(n.next.next.next == n)
        n = None        # Release reference.
        if sys.version_info[0] == 3 and sys.version_info[1] >= 4:
            #
            # In Python 3.4, objects with a __del__ method can still be collected.
            #
            gc.collect()
            test(PNodeI.counter == 0)
        else:
            #
            # The PNodeI class declares a __del__ method, which means the Python
            # garbage collector will NOT collect a cycle of PNodeI objects.
            #
            gc.collect()    # No effect.
            test(PNodeI.counter == 3)
            #
            # The uncollectable objects are stored in gc.garbage. We have to
            # manually break the cycle and then remove the objects from the
            # gc.garbage list.
            #
            test(len(gc.garbage) > 0)
            for o in gc.garbage:
                if isinstance(o, PNodeI):
                    o.next = None
            o = None        # Remove last reference.
            del gc.garbage[:]
            test(PNodeI.counter == 0)

        #
        # Obtain a preserved object from the server where the most-derived
        # type is unknown. The preserved slice refers to a graph of PNode
        # objects.
        #
        test(PNodeI.counter == 0)
        p = t.PBSUnknownAsPreservedWithGraph()
        test(p)
        test(PNodeI.counter == 3)
        t.checkPBSUnknownWithGraph(p)
        p = None        # Release reference.
        if sys.version_info[0] == 3 and sys.version_info[1] >= 4:
            #
            # In Python 3.4, objects with a __del__ method can still be collected.
            #
            gc.collect()
            test(PNodeI.counter == 0)
        else:
            #
            # The PNodeI class declares a __del__ method, which means the Python
            # garbage collector will NOT collect a cycle of PNodeI objects.
            #
            gc.collect()    # No effect.
            test(PNodeI.counter == 3)
            #
            # The uncollectable objects are stored in gc.garbage. We have to
            # manually break the cycle and then remove the objects from the
            # gc.garbage list.
            #
            test(len(gc.garbage) > 0)
            for o in gc.garbage:
                if isinstance(o, PNodeI):
                    o.next = None
            o = None        # Remove last reference.
            del gc.garbage[:]
            test(PNodeI.counter == 0)

        #
        # Register a factory in order to substitute our own subclass of
        # Preserved. This provides an easy way to determine how many
        # unmarshaled instances currently exist.
        #
        communicator.addValueFactory(PreservedFactoryI, Test.Preserved.ice_staticId())

        #
        # Obtain a preserved object from the server where the most-derived
        # type is unknown. A data member in the preserved slice refers to the
        # outer object, so the chain of references looks like this:
        #
        # outer->slicedData->outer
        #
        test(PreservedI.counter == 0)
        p = t.PBSUnknown2AsPreservedWithGraph()
        test(p != None)
        test(PreservedI.counter == 1)
        t.checkPBSUnknown2WithGraph(p)
        p._ice_slicedData = None    # Break the cycle.
        p = None                    # Release reference.
        test(PreservedI.counter == 0)

        #
        # Throw a preserved exception where the most-derived type is unknown.
        # The preserved exception slice contains a class data member. This
        # object is also preserved, and its most-derived type is also unknown.
        # The preserved slice of the object contains a class data member that
        # refers to itself.
        #
        # The chain of references looks like this:
        #
        # ex->slicedData->obj->slicedData->obj
        #
        try:
            test(PreservedI.counter == 0)

            try:
                t.throwPreservedException()
            except Test.PreservedException as ex:
                #
                # The class instance is only retained when the encoding is > 1.0.
                #
                if t.ice_getEncodingVersion() != Ice.Encoding_1_0:
                    test(PreservedI.counter == 1)
                    gc.collect()        # No effect.
                    test(PreservedI.counter == 1)
                    ex._ice_slicedData = None   # Break the cycle.

            #
            # Exception has gone out of scope.
            #
            if t.ice_getEncodingVersion() != Ice.Encoding_1_0:
                gc.collect()
                if sys.version_info[0] == 3 and sys.version_info[1] >= 4:
                    #
                    # In Python 3.4, objects with a __del__ method can still be collected.
                    #
                    test(len(gc.garbage) == 0)
                else:
                    test(len(gc.garbage) > 0)
                    for o in gc.garbage:
                        if isinstance(o, PreservedI):
                            o._ice_slicedData = None
                    o = None        # Remove last reference.
                    del gc.garbage[:]
                test(PreservedI.counter == 0)
        except Ice.Exception:
            test(False)
    except Ice.OperationNotExistException:
        pass

    print("ok")

    return t
Ejemplo n.º 35
0
def _bogus():
    w = Test.currentWidget()
    w.bogus()
Ejemplo n.º 36
0
 def returnOptionalClass(self, req, current=None):
     return Ice.Future.completed(Test.OneOptional(53))
Ejemplo n.º 37
0
def _delVectorItem(index):
    w = Test.currentWidget()
    del w[index]
Ejemplo n.º 38
0
 def opMStruct1(self, current):
     return Ice.Future.completed(
         Test.Initial.OpMStruct1MarshaledResult(Test.SmallStruct(),
                                                current))
Ejemplo n.º 39
0
def _createInterior():
    w = Test.currentWidget()
    for i in range(3):
	lb = Pmw.ScrolledListBox(w.interior(),
		items = range(20), listbox_height = 6)
	lb.pack(padx = 10, pady = 10)
Ejemplo n.º 40
0
def create_test_results():

    import shutil
    import os
    import FemGui
    import femresult.resulttools as resulttools
    from femtools import ccxtools

    stat_types = ["U1", "U2", "U3", "Uabs", "Sabs", "MaxPrin", "MidPrin", "MinPrin", "MaxShear", "Peeq", "Temp", "MFlow", "NPress"]
    temp_dir = testtools.get_fem_test_tmp_dir()
    static_analysis_dir = temp_dir + 'FEM_ccx_static/'
    frequency_analysis_dir = temp_dir + 'FEM_ccx_frequency/'
    thermomech_analysis_dir = temp_dir + 'FEM_ccx_thermomech/'
    Flow1D_thermomech_analysis_dir = temp_dir + 'FEM_ccx_Flow1D_thermomech/'

    # run all unit tests from this module
    import Test
    import sys
    current_module = sys.modules[__name__]
    Test.runTestsFromModule(current_module)

    # static cube
    FreeCAD.open(static_analysis_dir + 'cube_static.fcstd')
    FemGui.setActiveAnalysis(FreeCAD.ActiveDocument.Analysis)
    fea = ccxtools.FemToolsCcx()

    print("create static result files")
    fea.reset_all()
    fea.run()
    fea.load_results()
    stats_static = []
    for s in stat_types:
        statval = resulttools.get_stats(FreeCAD.ActiveDocument.getObject('CalculiX_static_results'), s)
        stats_static.append("{0}: ({1:.14g}, {2:.14g}, {3:.14g})\n".format(s, statval[0], statval[1], statval[2]))
    static_expected_values_file = static_analysis_dir + 'cube_static_expected_values'
    f = open(static_expected_values_file, 'w')
    for s in stats_static:
        f.write(s)
    f.close()
    frd_result_file = os.path.splitext(fea.inp_file_name)[0] + '.frd'
    dat_result_file = os.path.splitext(fea.inp_file_name)[0] + '.dat'
    frd_static_test_result_file = static_analysis_dir + 'cube_static.frd'
    dat_static_test_result_file = static_analysis_dir + 'cube_static.dat'
    shutil.copyfile(frd_result_file, frd_static_test_result_file)
    shutil.copyfile(dat_result_file, dat_static_test_result_file)

    # frequency cube
    FreeCAD.open(frequency_analysis_dir + 'cube_frequency.fcstd')
    FemGui.setActiveAnalysis(FreeCAD.ActiveDocument.Analysis)
    fea = ccxtools.FemToolsCcx()

    print("create frequency result files")
    fea.reset_all()
    fea.solver.EigenmodesCount = 1  # we should only have one result object
    fea.run()
    fea.load_results()
    stats_frequency = []
    for s in stat_types:
        statval = resulttools.get_stats(FreeCAD.ActiveDocument.getObject('CalculiX_frequency_mode_1_results'), s)
        stats_frequency.append("{0}: ({1:.14g}, {2:.14g}, {3:.14g})\n".format(s, statval[0], statval[1], statval[2]))
    frequency_expected_values_file = frequency_analysis_dir + 'cube_frequency_expected_values'
    f = open(frequency_expected_values_file, 'w')
    for s in stats_frequency:
        f.write(s)
    f.close()
    frd_frequency_test_result_file = frequency_analysis_dir + 'cube_frequency.frd'
    dat_frequency_test_result_file = frequency_analysis_dir + 'cube_frequency.dat'
    shutil.copyfile(frd_result_file, frd_frequency_test_result_file)
    shutil.copyfile(dat_result_file, dat_frequency_test_result_file)

    # thermomech
    print("create thermomech result files")
    FreeCAD.open(thermomech_analysis_dir + 'spine_thermomech.fcstd')
    FemGui.setActiveAnalysis(FreeCAD.ActiveDocument.Analysis)
    fea = ccxtools.FemToolsCcx()
    fea.reset_all()
    fea.run()
    fea.load_results()
    stats_thermomech = []
    for s in stat_types:
        statval = resulttools.get_stats(FreeCAD.ActiveDocument.getObject('CalculiX_thermomech_results'), s)
        stats_thermomech.append("{0}: ({1:.14g}, {2:.14g}, {3:.14g})\n".format(s, statval[0], statval[1], statval[2]))
    thermomech_expected_values_file = thermomech_analysis_dir + 'spine_thermomech_expected_values'
    f = open(thermomech_expected_values_file, 'w')
    for s in stats_thermomech:
        f.write(s)
    f.close()
    frd_result_file = os.path.splitext(fea.inp_file_name)[0] + '.frd'
    dat_result_file = os.path.splitext(fea.inp_file_name)[0] + '.dat'
    frd_thermomech_test_result_file = thermomech_analysis_dir + 'spine_thermomech.frd'
    dat_thermomech_test_result_file = thermomech_analysis_dir + 'spine_thermomech.dat'
    shutil.copyfile(frd_result_file, frd_thermomech_test_result_file)
    shutil.copyfile(dat_result_file, dat_thermomech_test_result_file)
    print('Results copied to the appropriate FEM test dirs in: ' + temp_dir)

    # Flow1D
    print("create Flow1D result files")
    FreeCAD.open(Flow1D_thermomech_analysis_dir + 'Flow1D_thermomech.fcstd')
    FemGui.setActiveAnalysis(FreeCAD.ActiveDocument.Analysis)
    fea = ccxtools.FemToolsCcx()
    fea.reset_all()
    fea.run()
    fea.load_results()
    stats_flow1D = []
    for s in stat_types:
        statval = resulttools.get_stats(FreeCAD.ActiveDocument.getObject('CalculiX_thermomech_time_1_0_results'), s)
        stats_flow1D.append("{0}: ({1:.14g}, {2:.14g}, {3:.14g})\n".format(s, statval[0], statval[1], statval[2]))
    Flow1D_thermomech_expected_values_file = Flow1D_thermomech_analysis_dir + 'Flow1D_thermomech_expected_values'
    f = open(Flow1D_thermomech_expected_values_file, 'w')
    for s in stats_flow1D:
        f.write(s)
    f.close()
    frd_result_file = os.path.splitext(fea.inp_file_name)[0] + '.frd'
    dat_result_file = os.path.splitext(fea.inp_file_name)[0] + '.dat'
    frd_Flow1D_thermomech_test_result_file = Flow1D_thermomech_analysis_dir + 'Flow1D_thermomech.frd'
    dat_Flow1D_thermomech_test_result_file = Flow1D_thermomech_analysis_dir + 'Flow1D_thermomech.dat'
    shutil.copyfile(frd_result_file, frd_Flow1D_thermomech_test_result_file)
    shutil.copyfile(dat_result_file, dat_Flow1D_thermomech_test_result_file)
    print('Flow1D thermomech results copied to the appropriate FEM test dirs in: ' + temp_dir)
Ejemplo n.º 41
0
def _getVectorItem(index):
    w = Test.currentWidget()
    return w[index]
Ejemplo n.º 42
0
def main():
    
    '''
    Train.train()
    '''
    Test.test()
Ejemplo n.º 43
0
def _setVectorItem(index, value):
    w = Test.currentWidget()
    w[index] = value
Ejemplo n.º 44
0
 def sequenceTest(self, p1, p2, current=None):
     ss = Test.SS3()
     ss.c1 = p1
     ss.c2 = p2
     return ss
Ejemplo n.º 45
0
# Tests for Blt widgets.

import os
import tkinter
import Test
import Pmw

Test.initialise()
testData = ()

# Blt vector type


def _setVectorItem(index, value):
    w = Test.currentWidget()
    w[index] = value


def _getVectorItem(index):
    w = Test.currentWidget()
    return w[index]


def _getVectorSlice(index1, index2):
    w = Test.currentWidget()
    return w[index1:index2]


def _delVectorItem(index):
    w = Test.currentWidget()
    del w[index]
Ejemplo n.º 46
0
def twoways(communicator, p):

    literals = p.opStringLiterals()

    test(Test.s0 == "\\")
    test(Test.s0 == Test.sw0)
    test(Test.s0 == literals[0])
    test(Test.s0 == literals[11])

    test(Test.s1 == "A")
    test(Test.s1 == Test.sw1)
    test(Test.s1 == literals[1])
    test(Test.s1 == literals[12])

    test(Test.s2 == "Ice")
    test(Test.s2 == Test.sw2)
    test(Test.s2 == literals[2])
    test(Test.s2 == literals[13])

    test(Test.s3 == "A21")
    test(Test.s3 == Test.sw3)
    test(Test.s3 == literals[3])
    test(Test.s3 == literals[14])

    test(Test.s4 == "\\u0041 \\U00000041")
    test(Test.s4 == Test.sw4)
    test(Test.s4 == literals[4])
    test(Test.s4 == literals[15])

    test(Test.s5 == "\xc3\xbf" if version_info[0] < 3 else b"\xc3\xbf".decode("utf-8"))
    test(Test.s5 == Test.sw5)
    test(Test.s5 == literals[5])
    test(Test.s5 == literals[16])

    test(Test.s6 == "\xcf\xbf" if version_info[0] < 3 else b"\xcf\xbf".decode("utf-8"))
    test(Test.s6 == Test.sw6)
    test(Test.s6 == literals[6])
    test(Test.s6 == literals[17])

    test(Test.s7 == "\xd7\xb0" if version_info[0] < 3 else b"\xd7\xb0".decode("utf-8"))
    test(Test.s7 == Test.sw7)
    test(Test.s7 == literals[7])
    test(Test.s7 == literals[18])

    test(Test.s8 == "\xf0\x90\x80\x80" if version_info[0] < 3 else b"\xf0\x90\x80\x80".decode("utf-8"))
    test(Test.s8 == Test.sw8)
    test(Test.s8 == literals[8])
    test(Test.s8 == literals[19])

    test(Test.s9 == "\xf0\x9f\x8d\x8c" if version_info[0] < 3 else b"\xf0\x9f\x8d\x8c".decode("utf-8"))
    test(Test.s9 == Test.sw9)
    test(Test.s9 == literals[9])
    test(Test.s9 == literals[20])

    test(Test.s10 == "\xe0\xb6\xa7" if version_info[0] < 3 else b"\xe0\xb6\xa7".decode("utf-8"))
    test(Test.s10 == Test.sw10)
    test(Test.s10 == literals[10])
    test(Test.s10 == literals[21])

    test(Test.ss0 == "\'\"\x3f\\\a\b\f\n\r\t\v\x06")
    test(Test.ss0 == Test.ss1)
    test(Test.ss0 == Test.ss2)
    test(Test.ss0 == literals[22])
    test(Test.ss0 == literals[23])
    test(Test.ss0 == literals[24])

    test(Test.ss3 == "\\\\U\\u\\")
    test(Test.ss3 == literals[25])

    test(Test.ss4 == "\\A\\")
    test(Test.ss4 == literals[26])

    test(Test.ss5 == "\\u0041\\")
    test(Test.ss5 == literals[27])

    test(Test.su0 == Test.su1)
    test(Test.su0 == Test.su2)
    test(Test.su0 == literals[28])
    test(Test.su0 == literals[29])
    test(Test.su0 == literals[30])

    #
    # ice_ping
    #
    p.ice_ping()

    #
    # ice_isA
    #
    test(p.ice_isA(Test.MyClass.ice_staticId()))

    #
    # ice_ids
    #
    ids = p.ice_ids()
    test(len(ids) == 3)
    test(ids[0] == "::Ice::Object")
    test(ids[1] == "::Test::MyClass")
    test(ids[2] == "::Test::MyDerivedClass")

    #
    # ice_id
    #
    test(p.ice_id() == Test.MyDerivedClass.ice_staticId())

    #
    # Prx ice_staticId
    #
    test(Test.MyClassPrx.ice_staticId() == Test.MyClass.ice_staticId())
    test(Test.MyDerivedClassPrx.ice_staticId() == Test.MyDerivedClass.ice_staticId())
    test(Ice.ObjectPrx.ice_staticId() == Ice.Object.ice_staticId())

    #
    # opVoid
    #
    p.opVoid()

    #
    # opByte
    #
    r, b = p.opByte(0xff, 0x0f)
    test(b == 0xf0)
    test(r == 0xff)

    #
    # opBool
    #
    r, b = p.opBool(True, False)
    test(b)
    test(not r)

    #
    # opShortIntLong
    #
    r, s, i, l = p.opShortIntLong(10, 11, 12)
    test(s == 10)
    test(i == 11)
    test(l == 12)
    test(r == 12)

    r, s, i, l = p.opShortIntLong(-32768, -2147483648, -9223372036854775808)
    test(s == -32768)
    test(i == -2147483648)
    test(l == -9223372036854775808)
    test(r == -9223372036854775808)

    r, s, i, l = p.opShortIntLong(32767, 2147483647, 9223372036854775807)
    test(s == 32767)
    test(i == 2147483647)
    test(l == 9223372036854775807)
    test(r == 9223372036854775807)

    #
    # opFloatDouble
    #
    r, f, d = p.opFloatDouble(3.14, 1.1E10)
    test(f - 3.14 < 0.001)
    test(d == 1.1E10)
    test(r == 1.1E10)

    #
    # Test invalid ranges for numbers
    #
    try:
        r, b = p.opByte(0x01ff, 0x01ff)
        test(False)
    except ValueError:
        pass

    try:
        r, s, i, l = p.opShortIntLong(32767 + 1, 0, 0)
        test(False)
    except ValueError:
        pass

    try:
        r, s, i, l = p.opShortIntLong(-32768 -1, 0, 0)
        test(False)
    except ValueError:
        pass

    try:
        r, s, i, l = p.opShortIntLong(0, 2147483647 + 1, 0)
        test(False)
    except ValueError:
        pass

    try:
        r, s, i, l = p.opShortIntLong(0, -2147483648 - 1, 0)
        test(False)
    except ValueError:
        pass

    try:
        r, s, i, l = p.opShortIntLong(0, 0, 9223372036854775807 + 1)
        test(False)
    except ValueError:
        pass

    try:
        r, s, i, l = p.opShortIntLong(0, 0, -9223372036854775808 - 1)
        test(False)
    except ValueError:
        pass

    r, f, d = p.opFloatDouble(3.402823466E38, 0.0)
    r, f, d = p.opFloatDouble(-3.402823466E38, 0.0)

    for val in ('inf', '-inf'):
        r, f, d = p.opFloatDouble(float(val), float(val))
        test(math.isinf(r) and math.isinf(f) and math.isinf(d))
    for val in ('nan', '-nan'):
        r, f, d = p.opFloatDouble(float(val), float(val))
        test(math.isnan(r) and math.isnan(f) and math.isnan(d))

    try:
        r, f, d = p.opFloatDouble(3.402823466E38*2, 0.0)
        test(False)
    except ValueError:
        pass

    try:
        r, f, d = p.opFloatDouble(-3.402823466E38*2, 0.0)
        test(False)
    except ValueError:
        pass

    #
    # opString
    #
    r, s = p.opString("hello", "world")
    test(s == "world hello")
    test(r == "hello world")
    if sys.version_info[0] == 2:
        r, s = p.opString(unicode("hello"), unicode("world"))
        test(s == "world hello")
        test(r == "hello world")

    #
    # opMyEnum
    #
    r, e = p.opMyEnum(Test.MyEnum.enum2)
    test(e == Test.MyEnum.enum2)
    test(r == Test.MyEnum.enum3)

    #
    # opMyClass
    #
    r, c1, c2 = p.opMyClass(p)
    test(Ice.proxyIdentityAndFacetEqual(c1, p))
    test(not Ice.proxyIdentityAndFacetEqual(c2, p))
    test(Ice.proxyIdentityAndFacetEqual(r, p))
    test(c1.ice_getIdentity() == Ice.stringToIdentity("test"))
    test(c2.ice_getIdentity() == Ice.stringToIdentity("noSuchIdentity"))
    test(r.ice_getIdentity() == Ice.stringToIdentity("test"))
    r.opVoid()
    c1.opVoid()
    try:
        c2.opVoid()
        test(False)
    except Ice.ObjectNotExistException:
        pass

    r, c1, c2 = p.opMyClass(None)
    test(not c1)
    test(c2)
    test(Ice.proxyIdentityAndFacetEqual(r, p))
    r.opVoid()

    #
    # opStruct
    #
    si1 = Test.Structure()
    si1.p = p
    si1.e = Test.MyEnum.enum3
    si1.s = Test.AnotherStruct()
    si1.s.s = "abc"
    si2 = Test.Structure()
    si2.p = None
    si2.e = Test.MyEnum.enum2
    si2.s = Test.AnotherStruct()
    si2.s.s = "def"

    rso, so = p.opStruct(si1, si2)
    test(not rso.p)
    test(rso.e == Test.MyEnum.enum2)
    test(rso.s.s == "def")
    test(so.p == p)
    test(so.e == Test.MyEnum.enum3)
    test(so.s.s == "a new string")
    so.p.opVoid()

    # Test marshalling of null structs and structs with null members.
    si1 = Test.Structure()
    si2 = None

    rso, so = p.opStruct(si1, si2)
    test(rso.p is None)
    test(rso.e == Test.MyEnum.enum1)
    test(rso.s.s == "")
    test(so.p is None)
    test(so.e == Test.MyEnum.enum1)
    test(so.s.s == "a new string")

    #
    # opByteS
    #
    bsi1 = (0x01, 0x11, 0x12, 0x22)
    bsi2 = (0xf1, 0xf2, 0xf3, 0xf4)

    rso, bso = p.opByteS(bsi1, bsi2)
    test(len(bso) == 4)
    test(len(rso) == 8)
    if sys.version_info[0] == 2:
        test(bso[0] == '\x22')
        test(bso[1] == '\x12')
        test(bso[2] == '\x11')
        test(bso[3] == '\x01')
        test(rso[0] == '\x01')
        test(rso[1] == '\x11')
        test(rso[2] == '\x12')
        test(rso[3] == '\x22')
        test(rso[4] == '\xf1')
        test(rso[5] == '\xf2')
        test(rso[6] == '\xf3')
        test(rso[7] == '\xf4')
    else:
        test(bso[0] == 0x22)
        test(bso[1] == 0x12)
        test(bso[2] == 0x11)
        test(bso[3] == 0x01)
        test(rso[0] == 0x01)
        test(rso[1] == 0x11)
        test(rso[2] == 0x12)
        test(rso[3] == 0x22)
        test(rso[4] == 0xf1)
        test(rso[5] == 0xf2)
        test(rso[6] == 0xf3)
        test(rso[7] == 0xf4)

    #
    # opByteS (array)
    #
    bsi1 = array.array('B')
    bsi1.fromlist([0x01, 0x11, 0x12, 0x22])
    bsi2 = array.array('B')
    bsi2.fromlist([0xf1, 0xf2, 0xf3, 0xf4])

    rso, bso = p.opByteS(bsi1, bsi2)
    test(len(bso) == 4)
    test(len(rso) == 8)
    if sys.version_info[0] == 2:
        test(bso[0] == '\x22')
        test(bso[1] == '\x12')
        test(bso[2] == '\x11')
        test(bso[3] == '\x01')
        test(rso[0] == '\x01')
        test(rso[1] == '\x11')
        test(rso[2] == '\x12')
        test(rso[3] == '\x22')
        test(rso[4] == '\xf1')
        test(rso[5] == '\xf2')
        test(rso[6] == '\xf3')
        test(rso[7] == '\xf4')
    else:
        test(bso[0] == 0x22)
        test(bso[1] == 0x12)
        test(bso[2] == 0x11)
        test(bso[3] == 0x01)
        test(rso[0] == 0x01)
        test(rso[1] == 0x11)
        test(rso[2] == 0x12)
        test(rso[3] == 0x22)
        test(rso[4] == 0xf1)
        test(rso[5] == 0xf2)
        test(rso[6] == 0xf3)
        test(rso[7] == 0xf4)

    #
    # opBoolS
    #
    bsi1 = (True, True, False)
    bsi2 = (False,)

    rso, bso = p.opBoolS(bsi1, bsi2)
    test(len(bso) == 4)
    test(bso[0])
    test(bso[1])
    test(not bso[2])
    test(not bso[3])
    test(len(rso) == 3)
    test(not rso[0])
    test(rso[1])
    test(rso[2])

    #
    # opBoolS (array)
    #
    bsi1 = array.array('B')
    bsi1.fromlist([1, 1, 0])
    bsi2 = array.array('B')
    bsi2.fromlist([0])

    rso, bso = p.opBoolS(bsi1, bsi2)
    test(len(bso) == 4)
    test(bso[0])
    test(bso[1])
    test(not bso[2])
    test(not bso[3])
    test(len(rso) == 3)
    test(not rso[0])
    test(rso[1])
    test(rso[2])

    #
    # opShortIntLongS
    #
    ssi = (1, 2, 3)
    isi = (5, 6, 7, 8)
    lsi = (10, 30, 20)

    rso, sso, iso, lso = p.opShortIntLongS(ssi, isi, lsi)
    test(len(sso) == 3)
    test(sso[0] == 1)
    test(sso[1] == 2)
    test(sso[2] == 3)
    test(len(iso) == 4)
    test(iso[0] == 8)
    test(iso[1] == 7)
    test(iso[2] == 6)
    test(iso[3] == 5)
    test(len(lso) == 6)
    test(lso[0] == 10)
    test(lso[1] == 30)
    test(lso[2] == 20)
    test(lso[3] == 10)
    test(lso[4] == 30)
    test(lso[5] == 20)
    test(len(rso) == 3)
    test(rso[0] == 10)
    test(rso[1] == 30)
    test(rso[2] == 20)

    #
    # opShortIntLongS (array)
    #
    ssi = array.array('h')
    ssi.fromlist([1, 2, 3])
    isi = array.array('i')
    isi.fromlist([5, 6, 7, 8])
    lsi = (10, 30, 20)  # Can't store Ice::Long in an array.

    rso, sso, iso, lso = p.opShortIntLongS(ssi, isi, lsi)
    test(len(sso) == 3)
    test(sso[0] == 1)
    test(sso[1] == 2)
    test(sso[2] == 3)
    test(len(iso) == 4)
    test(iso[0] == 8)
    test(iso[1] == 7)
    test(iso[2] == 6)
    test(iso[3] == 5)
    test(len(lso) == 6)
    test(lso[0] == 10)
    test(lso[1] == 30)
    test(lso[2] == 20)
    test(lso[3] == 10)
    test(lso[4] == 30)
    test(lso[5] == 20)
    test(len(rso) == 3)
    test(rso[0] == 10)
    test(rso[1] == 30)
    test(rso[2] == 20)

    #
    # opFloatDoubleS
    #
    fsi = (3.14, 1.11)
    dsi = (1.1E10, 1.2E10, 1.3E10)

    rso, fso, dso = p.opFloatDoubleS(fsi, dsi)
    test(len(fso) == 2)
    test(fso[0] - 3.14 < 0.001)
    test(fso[1] - 1.11 < 0.001)
    test(len(dso) == 3)
    test(dso[0] == 1.3E10)
    test(dso[1] == 1.2E10)
    test(dso[2] == 1.1E10)
    test(len(rso) == 5)
    test(rso[0] == 1.1E10)
    test(rso[1] == 1.2E10)
    test(rso[2] == 1.3E10)
    test(rso[3] - 3.14 < 0.001)
    test(rso[4] - 1.11 < 0.001)

    #
    # opFloatDoubleS (array)
    #
    fsi = array.array('f')
    fsi.fromlist([3.14, 1.11])
    dsi = array.array('d')
    dsi.fromlist([1.1E10, 1.2E10, 1.3E10])

    rso, fso, dso = p.opFloatDoubleS(fsi, dsi)
    test(len(fso) == 2)
    test(fso[0] - 3.14 < 0.001)
    test(fso[1] - 1.11 < 0.001)
    test(len(dso) == 3)
    test(dso[0] == 1.3E10)
    test(dso[1] == 1.2E10)
    test(dso[2] == 1.1E10)
    test(len(rso) == 5)
    test(rso[0] == 1.1E10)
    test(rso[1] == 1.2E10)
    test(rso[2] == 1.3E10)
    test(rso[3] - 3.14 < 0.001)
    test(rso[4] - 1.11 < 0.001)

    #
    # opStringS
    #
    ssi1 = ('abc', 'de', 'fghi')
    ssi2 = ('xyz',)

    rso, sso = p.opStringS(ssi1, ssi2)
    test(len(sso) == 4)
    test(sso[0] == "abc")
    test(sso[1] == "de")
    test(sso[2] == "fghi")
    test(sso[3] == "xyz")
    test(len(rso) == 3)
    test(rso[0] == "fghi")
    test(rso[1] == "de")
    test(rso[2] == "abc")

    #
    # opByteSS
    #
    bsi1 = ((0x01, 0x11, 0x12), (0xff,))
    bsi2 = ((0x0e,), (0xf2, 0xf1))

    rso, bso = p.opByteSS(bsi1, bsi2)
    test(len(bso) == 2)
    test(len(bso[0]) == 1)
    test(len(bso[1]) == 3)
    test(len(rso) == 4)
    test(len(rso[0]) == 3)
    test(len(rso[1]) == 1)
    test(len(rso[2]) == 1)
    test(len(rso[3]) == 2)
    if sys.version_info[0] == 2:
        test(bso[0][0] == '\xff')
        test(bso[1][0] == '\x01')
        test(bso[1][1] == '\x11')
        test(bso[1][2] == '\x12')
        test(rso[0][0] == '\x01')
        test(rso[0][1] == '\x11')
        test(rso[0][2] == '\x12')
        test(rso[1][0] == '\xff')
        test(rso[2][0] == '\x0e')
        test(rso[3][0] == '\xf2')
        test(rso[3][1] == '\xf1')
    else:
        test(bso[0][0] == 0xff)
        test(bso[1][0] == 0x01)
        test(bso[1][1] == 0x11)
        test(bso[1][2] == 0x12)
        test(rso[0][0] == 0x01)
        test(rso[0][1] == 0x11)
        test(rso[0][2] == 0x12)
        test(rso[1][0] == 0xff)
        test(rso[2][0] == 0x0e)
        test(rso[3][0] == 0xf2)
        test(rso[3][1] == 0xf1)

    #
    # opBoolSS
    #
    bsi1 = ((True,), (False,), (True, True),)
    bsi2 = ((False, False, True),)

    rso, bso = p.opBoolSS(bsi1, bsi2)
    test(len(bso) == 4)
    test(len(bso[0]) == 1)
    test(bso[0][0])
    test(len(bso[1]) == 1)
    test(not bso[1][0])
    test(len(bso[2]) == 2)
    test(bso[2][0])
    test(bso[2][1])
    test(len(bso[3]) == 3)
    test(not bso[3][0])
    test(not bso[3][1])
    test(bso[3][2])
    test(len(rso) == 3)
    test(len(rso[0]) == 2)
    test(rso[0][0])
    test(rso[0][1])
    test(len(rso[1]) == 1)
    test(not rso[1][0])
    test(len(rso[2]) == 1)
    test(rso[2][0])

    #
    # opShortIntLongSS
    #
    ssi = ((1,2,5), (13,), ())
    isi = ((24, 98), (42,))
    lsi = ((496, 1729),)

    rso, sso, iso, lso = p.opShortIntLongSS(ssi, isi, lsi)
    test(len(rso) == 1)
    test(len(rso[0]) == 2)
    test(rso[0][0] == 496)
    test(rso[0][1] == 1729)
    test(len(sso) == 3)
    test(len(sso[0]) == 3)
    test(sso[0][0] == 1)
    test(sso[0][1] == 2)
    test(sso[0][2] == 5)
    test(len(sso[1]) == 1)
    test(sso[1][0] == 13)
    test(len(sso[2]) == 0)
    test(len(iso) == 2)
    test(len(iso[0]) == 1)
    test(iso[0][0] == 42)
    test(len(iso[1]) == 2)
    test(iso[1][0] == 24)
    test(iso[1][1] == 98)
    test(len(lso) == 2)
    test(len(lso[0]) == 2)
    test(lso[0][0] == 496)
    test(lso[0][1] == 1729)
    test(len(lso[1]) == 2)
    test(lso[1][0] == 496)
    test(lso[1][1] == 1729)

    #
    # opFloatDoubleSS
    #
    fsi = ((3.14,), (1.11,), ())
    dsi = ((1.1E10, 1.2E10, 1.3E10),)

    rso, fso, dso = p.opFloatDoubleSS(fsi, dsi)
    test(len(fso) == 3)
    test(len(fso[0]) == 1)
    test(fso[0][0] - 3.14 < 0.001)
    test(len(fso[1]) == 1)
    test(fso[1][0] - 1.11 < 0.001)
    test(len(fso[2]) == 0)
    test(len(dso) == 1)
    test(len(dso[0]) == 3)
    test(dso[0][0] == 1.1E10)
    test(dso[0][1] == 1.2E10)
    test(dso[0][2] == 1.3E10)
    test(len(rso) == 2)
    test(len(rso[0]) == 3)
    test(rso[0][0] == 1.1E10)
    test(rso[0][1] == 1.2E10)
    test(rso[0][2] == 1.3E10)
    test(len(rso[1]) == 3)
    test(rso[1][0] == 1.1E10)
    test(rso[1][1] == 1.2E10)
    test(rso[1][2] == 1.3E10)

    #
    # opStringSS
    #
    ssi1 = (('abc',), ('de', 'fghi'))
    ssi2 = ((), (), ('xyz',))

    rso, sso = p.opStringSS(ssi1, ssi2)
    test(len(sso) == 5)
    test(len(sso[0]) == 1)
    test(sso[0][0] == "abc")
    test(len(sso[1]) == 2)
    test(sso[1][0] == "de")
    test(sso[1][1] == "fghi")
    test(len(sso[2]) == 0)
    test(len(sso[3]) == 0)
    test(len(sso[4]) == 1)
    test(sso[4][0] == "xyz")
    test(len(rso) == 3)
    test(len(rso[0]) == 1)
    test(rso[0][0] == "xyz")
    test(len(rso[1]) == 0)
    test(len(rso[2]) == 0)

    #
    # opStringSSS
    #
    sssi1 = ((('abc', 'de'), ('xyz',)), (('hello',),))
    sssi2 = ((('', ''), ('abcd',)), (('',),), ())

    rsso, ssso = p.opStringSSS(sssi1, sssi2)
    test(len(ssso) == 5)
    test(len(ssso[0]) == 2)
    test(len(ssso[0][0]) == 2)
    test(len(ssso[0][1]) == 1)
    test(len(ssso[1]) == 1)
    test(len(ssso[1][0]) == 1)
    test(len(ssso[2]) == 2)
    test(len(ssso[2][0]) == 2)
    test(len(ssso[2][1]) == 1)
    test(len(ssso[3]) == 1)
    test(len(ssso[3][0]) == 1)
    test(len(ssso[4]) == 0)
    test(ssso[0][0][0] == "abc")
    test(ssso[0][0][1] == "de")
    test(ssso[0][1][0] == "xyz")
    test(ssso[1][0][0] == "hello")
    test(ssso[2][0][0] == "")
    test(ssso[2][0][1] == "")
    test(ssso[2][1][0] == "abcd")
    test(ssso[3][0][0] == "")

    test(len(rsso) == 3)
    test(len(rsso[0]) == 0)
    test(len(rsso[1]) == 1)
    test(len(rsso[1][0]) == 1)
    test(len(rsso[2]) == 2)
    test(len(rsso[2][0]) == 2)
    test(len(rsso[2][1]) == 1)
    test(rsso[1][0][0] == "")
    test(rsso[2][0][0] == "")
    test(rsso[2][0][1] == "")
    test(rsso[2][1][0] == "abcd")

    #
    # opByteBoolD
    #
    di1 = {10: True, 100: False}
    di2 = {10: True, 11: False, 101: True}

    ro, do = p.opByteBoolD(di1, di2)

    test(do == di1)
    test(len(ro) == 4)
    test(ro[10])
    test(not ro[11])
    test(not ro[100])
    test(ro[101])

    #
    # opShortIntD
    #
    di1 = {110: -1, 1100: 123123}
    di2 = {110: -1, 111: -100, 1101: 0}

    ro, do = p.opShortIntD(di1, di2)

    test(do == di1)
    test(len(ro) == 4)
    test(ro[110] == -1)
    test(ro[111] == -100)
    test(ro[1100] == 123123)
    test(ro[1101] == 0)

    #
    # opLongFloatD
    #
    di1 = {999999110: -1.1, 999999111: 123123.2}
    di2 = {999999110: -1.1, 999999120: -100.4, 999999130: 0.5}

    ro, do = p.opLongFloatD(di1, di2)

    for k in do:
        test(math.fabs(do[k] - di1[k]) < 0.01)
    test(len(ro) == 4)
    test(ro[999999110] - -1.1 < 0.01)
    test(ro[999999120] - -100.4 < 0.01)
    test(ro[999999111] - 123123.2 < 0.01)
    test(ro[999999130] - 0.5 < 0.01)

    #
    # opStringStringD
    #
    di1 = {'foo': 'abc -1.1', 'bar': 'abc 123123.2'}
    di2 = {'foo': 'abc -1.1', 'FOO': 'abc -100.4', 'BAR': 'abc 0.5'}

    ro, do = p.opStringStringD(di1, di2)

    test(do == di1)
    test(len(ro) == 4)
    test(ro["foo"] == "abc -1.1")
    test(ro["FOO"] == "abc -100.4")
    test(ro["bar"] == "abc 123123.2")
    test(ro["BAR"] == "abc 0.5")

    #
    # opStringMyEnumD
    #
    di1 = {'abc': Test.MyEnum.enum1, '': Test.MyEnum.enum2}
    di2 = {'abc': Test.MyEnum.enum1, 'qwerty': Test.MyEnum.enum3, 'Hello!!': Test.MyEnum.enum2}

    ro, do = p.opStringMyEnumD(di1, di2)

    test(do == di1)
    test(len(ro) == 4)
    test(ro["abc"] == Test.MyEnum.enum1)
    test(ro["qwerty"] == Test.MyEnum.enum3)
    test(ro[""] == Test.MyEnum.enum2)
    test(ro["Hello!!"] == Test.MyEnum.enum2)

    #
    # opMyEnumStringD
    #
    di1 = {Test.MyEnum.enum1: 'abc'}
    di2 = {Test.MyEnum.enum2: 'Hello!!', Test.MyEnum.enum3: 'qwerty'}

    ro, do = p.opMyEnumStringD(di1, di2)

    test(do == di1)
    test(len(ro) == 3)
    test(ro[Test.MyEnum.enum1] == "abc")
    test(ro[Test.MyEnum.enum2] == "Hello!!")
    test(ro[Test.MyEnum.enum3] == "qwerty")

    #
    # opMyStructMyEnumD
    #
    s11 = Test.MyStruct()
    s11.i = 1
    s11.j = 1
    s12 = Test.MyStruct()
    s12.i = 1
    s12.j = 2
    s22 = Test.MyStruct()
    s22.i = 2
    s22.j = 2
    s23 = Test.MyStruct()
    s23.i = 2
    s23.j = 3
    di1 = {s11: Test.MyEnum.enum1, s12: Test.MyEnum.enum2}
    di2 = {s11: Test.MyEnum.enum1, s22: Test.MyEnum.enum3, s23: Test.MyEnum.enum2}

    ro, do = p.opMyStructMyEnumD(di1, di2)

    test(do == di1)
    test(len(ro) == 4)
    test(ro[s11] == Test.MyEnum.enum1)
    test(ro[s12] == Test.MyEnum.enum2)
    test(ro[s22] == Test.MyEnum.enum3)
    test(ro[s23] == Test.MyEnum.enum2)

    #
    # opByteBoolDS
    #
    dsi1 = ({ 10: True, 100: False }, { 10: True, 11: False, 101: True })
    dsi2 = ({ 100: False, 101: False },)

    ro, do = p.opByteBoolDS(dsi1, dsi2)

    test(len(ro) == 2)
    test(len(ro[0]) == 3)
    test(ro[0][10])
    test(not ro[0][11])
    test(ro[0][101])
    test(len(ro[1]) == 2)
    test(ro[1][10])
    test(not ro[1][100])
    test(len(do) == 3)
    test(len(do[0]) == 2)
    test(not do[0][100])
    test(not do[0][101])
    test(len(do[1]) == 2)
    test(do[1][10])
    test(not do[1][100])
    test(len(do[2]) == 3)
    test(do[2][10])
    test(not do[2][11])
    test(do[2][101])

    #
    # opShortIntDS
    #
    dsi1 = ({ 110: -1, 1100: 123123 }, { 110: -1, 111: -100, 1101: 0 })
    dsi2 = ({ 100: -1001 },)

    ro, do = p.opShortIntDS(dsi1, dsi2)

    test(len(ro) == 2)
    test(len(ro[0]) == 3)
    test(ro[0][110] == -1)
    test(ro[0][111] == -100)
    test(ro[0][1101] == 0)
    test(len(ro[1]) == 2)
    test(ro[1][110] == -1)
    test(ro[1][1100] == 123123)

    test(len(do) == 3)
    test(len(do[0]) == 1)
    test(do[0][100] == -1001)
    test(len(do[1]) == 2)
    test(do[1][110] == -1)
    test(do[1][1100] == 123123)
    test(len(do[2]) == 3)
    test(do[2][110] == -1)
    test(do[2][111] == -100)
    test(do[2][1101] == 0)

    #
    # opLongFloatDS
    #
    dsi1 = ({ 999999110: -1.1, 999999111: 123123.2 }, { 999999110: -1.1, 999999120: -100.4, 999999130: 0.5 })
    dsi2 = ({ 999999140: 3.14 },)

    ro, do = p.opLongFloatDS(dsi1, dsi2)

    test(len(ro) == 2)
    test(len(ro[0]) == 3)
    test(ro[0][999999110] - -1.1 < 0.01)
    test(ro[0][999999120] - -100.4 < 0.01)
    test(ro[0][999999130] - 0.5 < 0.01)
    test(len(ro[1]) == 2)
    test(ro[1][999999110] - -1.1 < 0.01)
    test(ro[1][999999111] - 123123.2 < 0.01)

    test(len(do) == 3)
    test(len(do[0]) == 1)
    test(do[0][999999140] - 3.14 < 0.01)
    test(len(do[1]) == 2)
    test(do[1][999999110] - -1.1 < 0.01)
    test(do[1][999999111] - 123123.2 < 0.01)
    test(len(do[2]) == 3)
    test(do[2][999999110] - -1.1 < 0.01)
    test(do[2][999999120] - -100.4 < 0.01)
    test(do[2][999999130] - 0.5 < 0.01)

    #
    # opStringStringDS
    #

    dsi1 = ({ "foo": "abc -1.1", "bar": "abc 123123.2" }, { "foo": "abc -1.1", "FOO": "abc -100.4", "BAR": "abc 0.5" })
    dsi2 = ({ "f00": "ABC -3.14" },)

    ro, do = p.opStringStringDS(dsi1, dsi2)

    test(len(ro) == 2)
    test(len(ro[0]) == 3)
    test(ro[0]["foo"] == "abc -1.1")
    test(ro[0]["FOO"] == "abc -100.4")
    test(ro[0]["BAR"] == "abc 0.5")
    test(len(ro[1]) == 2)
    test(ro[1]["foo"] == "abc -1.1")
    test(ro[1]["bar"] == "abc 123123.2")

    test(len(do) == 3)
    test(len(do[0]) == 1)
    test(do[0]["f00"] == "ABC -3.14")
    test(len(do[1]) == 2)
    test(do[1]["foo"] == "abc -1.1")
    test(do[1]["bar"] == "abc 123123.2")
    test(len(do[2]) == 3)
    test(do[2]["foo"] == "abc -1.1")
    test(do[2]["FOO"] == "abc -100.4")
    test(do[2]["BAR"] == "abc 0.5")

    #
    # opStringMyEnumDS
    #
    dsi1 = (
            { "abc": Test.MyEnum.enum1, "": Test.MyEnum.enum2 },
            { "abc": Test.MyEnum.enum1, "qwerty": Test.MyEnum.enum3, "Hello!!": Test.MyEnum.enum2 }
           )

    dsi2 = ({ "Goodbye": Test.MyEnum.enum1 },)

    ro, do = p.opStringMyEnumDS(dsi1, dsi2)

    test(len(ro) == 2)
    test(len(ro[0]) == 3)
    test(ro[0]["abc"] == Test.MyEnum.enum1)
    test(ro[0]["qwerty"] == Test.MyEnum.enum3)
    test(ro[0]["Hello!!"] == Test.MyEnum.enum2)
    test(len(ro[1]) == 2)
    test(ro[1]["abc"] == Test.MyEnum.enum1)
    test(ro[1][""] == Test.MyEnum.enum2)

    test(len(do) == 3)
    test(len(do[0]) == 1)
    test(do[0]["Goodbye"] == Test.MyEnum.enum1)
    test(len(do[1]) == 2)
    test(do[1]["abc"] == Test.MyEnum.enum1)
    test(do[1][""] == Test.MyEnum.enum2)
    test(len(do[2]) == 3)
    test(do[2]["abc"] == Test.MyEnum.enum1)
    test(do[2]["qwerty"] == Test.MyEnum.enum3)
    test(do[2]["Hello!!"] == Test.MyEnum.enum2)

    #
    # opMyEnumStringDS
    #
    dsi1 = ({ Test.MyEnum.enum1: 'abc' }, { Test.MyEnum.enum2: 'Hello!!', Test.MyEnum.enum3: 'qwerty'})
    dsi2 = ({ Test.MyEnum.enum1: 'Goodbye' },)

    ro, do = p.opMyEnumStringDS(dsi1, dsi2)

    test(len(ro) == 2)
    test(len(ro[0]) == 2)
    test(ro[0][Test.MyEnum.enum2] == "Hello!!")
    test(ro[0][Test.MyEnum.enum3] == "qwerty")
    test(len(ro[1]) == 1)
    test(ro[1][Test.MyEnum.enum1] == "abc")

    test(len(do) == 3)
    test(len(do[0]) == 1)
    test(do[0][Test.MyEnum.enum1] == "Goodbye")
    test(len(do[1]) == 1)
    test(do[1][Test.MyEnum.enum1] == "abc")
    test(len(do[2]) == 2)
    test(do[2][Test.MyEnum.enum2] == "Hello!!")
    test(do[2][Test.MyEnum.enum3] == "qwerty")

    #
    # opMyStructMyEnumDS
    #
    s11 = Test.MyStruct(1, 1)
    s12 = Test.MyStruct(1, 2)

    s22 = Test.MyStruct(2, 2)
    s23 = Test.MyStruct(2, 3)

    dsi1 = (
            { s11: Test.MyEnum.enum1, s12: Test.MyEnum.enum2 },
            { s11: Test.MyEnum.enum1, s22: Test.MyEnum.enum3, s23: Test.MyEnum.enum2 }
           )
    dsi2 = ({ s23: Test.MyEnum.enum3 },)

    ro, do = p.opMyStructMyEnumDS(dsi1, dsi2)

    test(len(ro) == 2)
    test(len(ro[0]) == 3)
    test(ro[0][s11] == Test.MyEnum.enum1)
    test(ro[0][s22] == Test.MyEnum.enum3)
    test(ro[0][s23] == Test.MyEnum.enum2)
    test(len(ro[1]) == 2)
    test(ro[1][s11] == Test.MyEnum.enum1)
    test(ro[1][s12] == Test.MyEnum.enum2)

    test(len(do) == 3)
    test(len(do[0]) == 1)
    test(do[0][s23] == Test.MyEnum.enum3)
    test(len(do[1]) == 2)
    test(do[1][s11] == Test.MyEnum.enum1)
    test(do[1][s12] == Test.MyEnum.enum2)
    test(len(do[2]) == 3)
    test(do[2][s11] == Test.MyEnum.enum1)
    test(do[2][s22] == Test.MyEnum.enum3)
    test(do[2][s23] == Test.MyEnum.enum2)

    #
    #opByteByteSD
    #
    sdi1 = { 0x01: (0x01, 0x11), 0x22: (0x12,) }
    sdi2 = { 0xf1: (0xf2, 0xf3) }

    ro, do = p.opByteByteSD(sdi1, sdi2)

    if sys.version_info[0] == 2:
        test(len(do) == 1)
        test(len(do[0xf1]) == 2)
        test(do[0xf1][0] == '\xf2')
        test(do[0xf1][1] == '\xf3')
        test(len(ro) == 3)
        test(len(ro[0x01]) == 2)
        test(ro[0x01][0] == '\x01')
        test(ro[0x01][1] == '\x11')
        test(len(ro[0x22]) == 1)
        test(ro[0x22][0] == '\x12')
        test(len(ro[0xf1]) == 2)
        test(ro[0xf1][0] == '\xf2')
        test(ro[0xf1][1] == '\xf3')
    else:
        test(len(do) == 1)
        test(len(do[0xf1]) == 2)
        test(do[0xf1][0] == 0xf2)
        test(do[0xf1][1] == 0xf3)
        test(len(ro) == 3)
        test(len(ro[0x01]) == 2)
        test(ro[0x01][0] == 0x01)
        test(ro[0x01][1] == 0x11)
        test(len(ro[0x22]) == 1)
        test(ro[0x22][0] == 0x12)
        test(len(ro[0xf1]) == 2)
        test(ro[0xf1][0] == 0xf2)
        test(ro[0xf1][1] == 0xf3)

    #
    # opBoolBoolSD
    #
    sdi1 = { False: (True, False), True: (False, True, True) }
    sdi2 = { False: (True, False) }

    ro, do = p.opBoolBoolSD(sdi1, sdi2)

    test(len(do) == 1)
    test(len(do[False]) == 2)
    test(do[False][0])
    test(not do[False][1])
    test(len(ro) == 2)
    test(len(ro[False]) == 2)
    test(ro[False][0])
    test(not ro[False][1])
    test(len(ro[True]) == 3)
    test(not ro[True][0])
    test(ro[True][1])
    test(ro[True][2])

    #
    # opShortShortSD
    #
    sdi1 = { 1: (1, 2, 3), 2: (4, 5) }
    sdi2 = { 4: (6, 7) }

    ro, do = p.opShortShortSD(sdi1, sdi2)

    test(len(do) == 1)
    test(len(do[4]) == 2)
    test(do[4][0] == 6)
    test(do[4][1] == 7)
    test(len(ro) == 3)
    test(len(ro[1]) == 3)
    test(ro[1][0] == 1)
    test(ro[1][1] == 2)
    test(ro[1][2] == 3)
    test(len(ro[2]) == 2)
    test(ro[2][0] == 4)
    test(ro[2][1] == 5)
    test(len(ro[4]) == 2)
    test(ro[4][0] == 6)
    test(ro[4][1] == 7)

    #
    # opIntIntSD
    #
    sdi1 = { 100: (100, 200, 300), 200: (400, 500) }
    sdi2 = { 400: (600, 700) }

    ro, do = p.opIntIntSD(sdi1, sdi2)

    test(len(do) == 1)
    test(len(do[400]) == 2)
    test(do[400][0] == 600)
    test(do[400][1] == 700)
    test(len(ro) == 3)
    test(len(ro[100]) == 3)
    test(ro[100][0] == 100)
    test(ro[100][1] == 200)
    test(ro[100][2] == 300)
    test(len(ro[200]) == 2)
    test(ro[200][0] == 400)
    test(ro[200][1] == 500)
    test(len(ro[400]) == 2)
    test(ro[400][0] == 600)
    test(ro[400][1] == 700)

    #
    # opLongLongSD
    #
    sdi1 = { 999999990: (999999110, 999999111, 999999110), 999999991: (999999120, 999999130) }
    sdi2 = { 999999992: (999999110, 999999120) }

    ro, do = p.opLongLongSD(sdi1, sdi2)

    test(len(do) == 1)
    test(len(do[999999992]) == 2)
    test(do[999999992][0] == 999999110)
    test(do[999999992][1] == 999999120)
    test(len(ro) == 3)
    test(len(ro[999999990]) == 3)
    test(ro[999999990][0] == 999999110)
    test(ro[999999990][1] == 999999111)
    test(ro[999999990][2] == 999999110)
    test(len(ro[999999991]) == 2)
    test(ro[999999991][0] == 999999120)
    test(ro[999999991][1] == 999999130)
    test(len(ro[999999992]) == 2)
    test(ro[999999992][0] == 999999110)
    test(ro[999999992][1] == 999999120)

    #
    # opStringFloatSD
    #
    sdi1 = { "abc": (-1.1, 123123.2, 100.0), "ABC": (42.24, -1.61) }
    sdi2 = { "aBc": (-3.14, 3.14) }

    ro, do = p.opStringFloatSD(sdi1, sdi2)

    test(len(do) == 1)
    test(len(do["aBc"]) == 2)
    test(do["aBc"][0] - -3.14 < 0.01)
    test(do["aBc"][1] - 3.14 < 0.01)

    test(len(ro) == 3)
    test(len(ro["abc"]) == 3)
    test(ro["abc"][0] - -1.1 < 0.01)
    test(ro["abc"][1] - 123123.2 < 0.01)
    test(ro["abc"][2] - 100.0 < 0.01)
    test(len(ro["ABC"]) == 2)
    test(ro["ABC"][0] - 42.24 < 0.01)
    test(ro["ABC"][1] - -1.61 < 0.01)
    test(len(ro["aBc"]) == 2)
    test(ro["aBc"][0] - -3.14 < 0.01)
    test(ro["aBc"][1] - 3.14 < 0.01)

    #
    # opStringDoubleSD
    #
    sdi1 = { "Hello!!": (1.1E10, 1.2E10, 1.3E10), "Goodbye": (1.4E10, 1.5E10) }
    sdi2 = { "": (1.6E10, 1.7E10) }

    ro, do = p.opStringDoubleSD(sdi1, sdi2)

    test(len(do) == 1)
    test(len(do[""]) == 2)
    test(do[""][0] == 1.6E10)
    test(do[""][1] == 1.7E10)
    test(len(ro) == 3)
    test(len(ro["Hello!!"]) == 3)
    test(ro["Hello!!"][0] == 1.1E10)
    test(ro["Hello!!"][1] == 1.2E10)
    test(ro["Hello!!"][2] == 1.3E10)
    test(len(ro["Goodbye"]) == 2)
    test(ro["Goodbye"][0] == 1.4E10)
    test(ro["Goodbye"][1] == 1.5E10)
    test(len(ro[""]) == 2)
    test(ro[""][0] == 1.6E10)
    test(ro[""][1] == 1.7E10)

    #
    # opStringStringSD
    #
    sdi1 = { "abc": ("abc", "de", "fghi") , "def": ("xyz", "or") }
    sdi2 = { "ghi": ("and", "xor") }

    ro, do = p.opStringStringSD(sdi1, sdi2)

    test(len(do) == 1)
    test(len(do["ghi"]) == 2)
    test(do["ghi"][0] == "and")
    test(do["ghi"][1] == "xor")
    test(len(ro) == 3)
    test(len(ro["abc"]) == 3)
    test(ro["abc"][0] == "abc")
    test(ro["abc"][1] == "de")
    test(ro["abc"][2] == "fghi")
    test(len(ro["def"]) == 2)
    test(ro["def"][0] == "xyz")
    test(ro["def"][1] == "or")
    test(len(ro["ghi"]) == 2)
    test(ro["ghi"][0] == "and")
    test(ro["ghi"][1] == "xor")

    #
    # opMyEnumMyEnumSD
    #
    sdi1 = {
            Test.MyEnum.enum3: (Test.MyEnum.enum1, Test.MyEnum.enum1, Test.MyEnum.enum2),
            Test.MyEnum.enum2: (Test.MyEnum.enum1, Test.MyEnum.enum2)
           }
    sdi2 = { Test.MyEnum.enum1: (Test.MyEnum.enum3, Test.MyEnum.enum3) }

    ro, do = p.opMyEnumMyEnumSD(sdi1, sdi2)

    test(len(do) == 1)
    test(len(do[Test.MyEnum.enum1]) == 2)
    test(do[Test.MyEnum.enum1][0] == Test.MyEnum.enum3)
    test(do[Test.MyEnum.enum1][1] == Test.MyEnum.enum3)
    test(len(ro) == 3)
    test(len(ro[Test.MyEnum.enum3]) == 3)
    test(ro[Test.MyEnum.enum3][0] == Test.MyEnum.enum1)
    test(ro[Test.MyEnum.enum3][1] == Test.MyEnum.enum1)
    test(ro[Test.MyEnum.enum3][2] == Test.MyEnum.enum2)
    test(len(ro[Test.MyEnum.enum2]) == 2)
    test(ro[Test.MyEnum.enum2][0] == Test.MyEnum.enum1)
    test(ro[Test.MyEnum.enum2][1] == Test.MyEnum.enum2)
    test(len(ro[Test.MyEnum.enum1]) == 2)
    test(ro[Test.MyEnum.enum1][0] == Test.MyEnum.enum3)
    test(ro[Test.MyEnum.enum1][1] == Test.MyEnum.enum3)

    #
    # opIntS
    #
    lengths = ( 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 )
    for l in lengths:
        s = []
        for i in range(l):
            s.append(i)
        r = p.opIntS(s)
        test(len(r) == l)
        for j in range(len(r)):
            test(r[j] == -j)

    #
    # opContext
    #
    ctx = {'one': 'ONE', 'two': 'TWO', 'three': 'THREE'}

    r = p.opContext()
    test(len(p.ice_getContext()) == 0)
    test(r != ctx)

    r = p.opContext(ctx)
    test(len(p.ice_getContext()) == 0)
    test(r == ctx)

    p2 = Test.MyClassPrx.checkedCast(p.ice_context(ctx))
    test(p2.ice_getContext() == ctx)
    r = p2.opContext()
    test(r == ctx)
    r = p2.opContext(ctx)
    test(r == ctx)

    #
    # Test implicit context propagation
    #
    if p.ice_getConnection():
        impls = ( 'Shared', 'PerThread' )
        for i in impls:
            initData = Ice.InitializationData()
            initData.properties = communicator.getProperties().clone()
            initData.properties.setProperty('Ice.ImplicitContext', i)
            ic = Ice.initialize(data=initData)

            ctx = {'one': 'ONE', 'two': 'TWO', 'three': 'THREE'}

            p1 = Test.MyClassPrx.uncheckedCast(ic.stringToProxy('test:default -p 12010'))

            ic.getImplicitContext().setContext(ctx)
            test(ic.getImplicitContext().getContext() == ctx)
            test(p1.opContext() == ctx)

            test(ic.getImplicitContext().containsKey('zero') == False)
            r = ic.getImplicitContext().put('zero', 'ZERO')
            test(r == '')
            test(ic.getImplicitContext().containsKey('zero') == True)
            test(ic.getImplicitContext().get('zero') == 'ZERO')

            ctx = ic.getImplicitContext().getContext()
            test(p1.opContext() == ctx)

            prxContext = {'one': 'UN', 'four': 'QUATRE'}

            combined = ctx.copy()
            combined.update(prxContext)
            test(combined['one'] == 'UN')

            p2 = Test.MyClassPrx.uncheckedCast(p1.ice_context(prxContext))

            ic.getImplicitContext().setContext({})
            test(p2.opContext() == prxContext)

            ic.getImplicitContext().setContext(ctx)
            test(p2.opContext() == combined)

            test(ic.getImplicitContext().remove('one') == 'ONE')

            ic.destroy()

    d = 1278312346.0 / 13.0
    ds = []
    for i in range(5):
        ds.append(d)
    p.opDoubleMarshaling(d, ds)

    #
    # opIdempotent
    #
    p.opIdempotent()

    #
    # opNonmutating
    #
    p.opNonmutating()

    test(p.opByte1(0xFF) == 0xFF)
    test(p.opShort1(0x7FFF) == 0x7FFF)
    test(p.opInt1(0x7FFFFFFF) == 0x7FFFFFFF)
    test(p.opLong1(0x7FFFFFFFFFFFFFFF) == 0x7FFFFFFFFFFFFFFF)
    test(p.opFloat1(1.0) == 1.0)
    test(p.opDouble1(1.0) == 1.0)
    test(p.opString1("opString1") == "opString1")
    test(len(p.opStringS1(None)) == 0)
    test(len(p.opByteBoolD1(None)) == 0)
    test(len(p.opStringS2(None)) == 0)
    test(len(p.opByteBoolD2(None)) == 0)

    d = Test.MyDerivedClassPrx.uncheckedCast(p)
    s = Test.MyStruct1()
    s.tesT = "Test.MyStruct1.s"
    s.myClass = None
    s.myStruct1 = "Test.MyStruct1.myStruct1"
    s = d.opMyStruct1(s)
    test(s.tesT == "Test.MyStruct1.s")
    test(s.myClass == None)
    test(s.myStruct1 == "Test.MyStruct1.myStruct1")
    c = Test.MyClass1()
    c.tesT = "Test.MyClass1.testT"
    c.myClass = None
    c.myClass1 = "Test.MyClass1.myClass1"
    c = d.opMyClass1(c)
    test(c.tesT == "Test.MyClass1.testT")
    test(c.myClass == None)
    test(c.myClass1 == "Test.MyClass1.myClass1")

    p1 = p.opMStruct1()
    p1.e = Test.MyEnum.enum3
    (p3, p2) = p.opMStruct2(p1)
    test(p2 == p1 and p3 == p1)

    p.opMSeq1()
    p1 = ["test"]
    (p3, p2) = p.opMSeq2(p1)
    test(p2[0] == "test" and p3[0] == "test")

    p.opMDict1()

    p1 = { "test": "test" }
    (p3, p2) = p.opMDict2(p1)
    test(p3["test"] == "test" and p2["test"] == "test")
Ejemplo n.º 47
0
            if '-kern' in args:
                fullarg = args[args.index("-kern")+1]
                kerntype = fullarg[:fullarg.rfind('_')]
                print kerntype
                dist = float(fullarg[fullarg.rfind('_')+1:])
                print dist
            else:
                kerntype = 'quartic'
                dist = 900000.0
        except:
            print "Kernel Argument is not formmated correctly"
            print "it should be something like quartic_900000 or epanech_800000 (units must be meters)"
            print "run with -help for more options"
            sys.exit("Error")

        Test.test(f, rf_std_in, b_direct, ulist, kerntype)
        
        
    #except:
    #    print "ERROR: THERE WAS A PROBLEM INTERPRETING THE ARGUMENTS"
    #    print "Must Specify -mode"
    #    print "Execute GWRMain.py -help  for information"
elif "-help" in sys.argv:
    print "---------------------"
    print "MODE ARGUMENTS"
    print "-mode"
    print "db_load ((-tf OR -df OR -tstf), -conn, -tbl)"
    print "Build_ref_files (-tf, -rf_std_out, -rf_obs_out, -wordlist(OPTIONAL))"
    print "NOT FUNCTIONAL: Create_Wu ((-tf OR -df OR -tstf), -kern, -ulist, -wu_dir_out)"
    print "NOT FUNCTIONAL: Create_Y ((-tf OR -df OR -tstf), -ulist, -y_dir_out)"
    print "Create_Wu_Y (-ptbl, -conn, -pointgrid(OPTIONAL), -kern(OPTIONAL), -zeroed(OPTOINAL), -ulist, -wu_y_dir_out, -rf_obs_in)"
Ejemplo n.º 48
0
# Based on iwidgets2.2.0/tests/dialog.test code.

import sys
import Tkinter
import Test
import Pmw

Test.initialise()

if Tkinter.TkVersion >= 8.3:
    version = sys.version_info
    if version[0] > 2 or (version[0] == 2 and version[1] > 0):
        expected1 = "AttributeError: Dialog instance has no attribute 'bogus'"
    else:
        expected1 = "AttributeError: 'Dialog' instance has no attribute 'bogus'"
else:
    expected1 = 'AttributeError: bogus'

c = Pmw.Dialog


def _addListbox():
    global _lb
    w = Test.currentWidget()
    _lb = Tkinter.Listbox(w.interior(), relief='sunken')
    _lb.pack(fill='both', expand='yes')


def _addListEntry(text):
    _lb.insert('end', text)
Ejemplo n.º 49
0
def _getTopPageName():
    w = Test.currentWidget()
    return w._topPageName
Ejemplo n.º 50
0
def _addListbox():
    global _lb
    w = Test.currentWidget()
    _lb = Tkinter.Listbox(w.interior(), relief='sunken')
    _lb.pack(fill='both', expand='yes')
    targetE.append([1,0,0,0,0])


#Values
inputsTraining = array(inputT)
targetTraining = array(targetT)
inputsEvaluting = array(valuate)
targetEvaluting = array(targetE)

#Neural network
inputNodes = 900
hiddenLayers = (60,)

outputNodes = 5

# Maximun and minimun value for wieght matrix
maxVal = 0.5
minVal = -0.5

doTraining = True # If it is true it will do the training, in other case it loads the old matrix.

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''  End parameters to configure
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''

weightMatrices = Test.get_weight_matrices(inputNodes,hiddenLayers,outputNodes,maxVal,minVal)

test = Test(inputsTraining,targetTraining,inputsEvaluting,targetEvaluting,20,0.1)

test.test(inputNodes,hiddenLayers,outputNodes,weightMatrices,doTraining)
Ejemplo n.º 52
0
def _test_deactivate(result):
    w = Test.currentWidget()
    w.after(Test.delay() + 4000,
            lambda widget=w, r=result: widget.deactivate(r))
Ejemplo n.º 53
0
 def opMG1(self, current):
     return Ice.Future.completed(
         Test.Initial.OpMG1MarshaledResult(Test.G(), current))
Ejemplo n.º 54
0
 def SBaseAsSBase(self, current=None):
     sb = Test.SBase()
     sb.sb = "SBase.sb"
     return sb
Ejemplo n.º 55
0
import Test
from Plex import *
import sys

lex = Lexicon([
  (Seq(Any("ab"), Rep(Any("ab01"))), 'ident'),
  (Seq(Any("01"), Rep(Any("01"))), 'num'),
  (Any(' \n'), IGNORE),
  (Str("abba"), 'abba'),
  (Any('([{!"#') + Rep(AnyBut('!"#}])')) + Any('!"#}])'), IGNORE)
],
debug = Test.debug,
timings = sys.stderr
)

Test.run(lex, "test2", debug = 0, trace = 0)


Ejemplo n.º 56
0
 def opOptionalException(self, a, b, o, current=None):
     f = Ice.Future()
     f.set_exception(Test.OptionalException(False, a, b, o))
     return f
Ejemplo n.º 57
0
if len(sys.argv) != 2:
    usageExit()

testName = sys.argv[1]
if testName not in tests:
    print 'Unknown test "' + testName + '"'
    usageExit()

if testName == 'reinitialise_test':
    # Run this by itself, since it calls Tkinter.Tk, mainloop, etc.
    reinitialise_test()
    sys.exit()

# Use Pmw version in this distribution:
Test.initialise()
root = Test.root
root.deiconify()

# To use a different version of Pmw, comment out the three above lines
# and the "import Test" line and uncomment these three:
#   root = Tkinter.Tk()
#   Pmw.setversion('1.0')
#   Pmw.initialise(root)

testFunction = locals()[testName]
testFunction()

if testName != 'memoryleak2_test':
    # This does not use mainloop.
    root.mainloop()
Ejemplo n.º 58
0
 def opDerivedException(self, a, b, o, current=None):
     f = Ice.Future()
     f.set_exception(Test.DerivedException(False, a, b, o, b, o))
     return f
Ejemplo n.º 59
0
# Based on iwidgets2.2.0/tests/entryfield.test code.

import tkinter
import Test
import Pmw

Test.initialise()

_myValidators = {"hello": (lambda s: s == "hello", len)}

c = Pmw.EntryField

kw_1 = {"entry_width": 12, "labelpos": "n", "label_text": "Entry Field:"}
tests_1 = (
    (c.pack, (), {"padx": 10, "pady": 10, "fill": "both", "expand": 1}),
    (Test.num_options, (), 10),
    ("errorbackground", "red"),
    ("hull_background", "yellow"),
    ("label_background", "yellow"),
    ("entry_background", "yellow"),
    ("hull_show", "X", 'TclError: unknown option "-show"'),
    ("entry_show", ""),
    ("entry_borderwidth", 4),
    ("entry_borderwidth", 2),
    ("command", Test.callback),
    ("hull_cursor", "gumby"),
    ("entry_exportselection", 0),
    ("label_foreground", "Green"),
    ("entry_foreground", "Green"),
    ("label_foreground", "Black"),
    ("entry_foreground", "Black"),
Ejemplo n.º 60
0
def twowaysNewAMI(communicator, p):
    cb = Callback()
    p.begin_ice_ping(cb.ping, cb.exCB)
    cb.check()

    cb = Callback()
    p.begin_ice_isA(Test.MyClass.ice_staticId(), cb.isA, cb.exCB)
    cb.check()

    cb = Callback()
    p.begin_ice_id(cb.id, cb.exCB)
    cb.check()

    cb = Callback()
    p.begin_ice_ids(cb.ids, cb.exCB)
    cb.check()

    r = p.begin_opVoid()
    p.end_opVoid(r)

    cb = Callback()
    p.begin_opVoid(cb.opVoid, cb.exCB)
    cb.check()

    r = p.begin_opByte(0xff, 0x0f)
    (ret, p3) = p.end_opByte(r)
    test(p3 == 0xf0)
    test(ret == 0xff)

    cb = Callback()
    p.begin_opByte(0xff, 0x0f, cb.opByte, cb.exCB)
    cb.check()

    cb = Callback()
    p.begin_opBool(True, False, cb.opBool, cb.exCB)
    cb.check()

    cb = Callback()
    p.begin_opShortIntLong(10, 11, 12, cb.opShortIntLong, cb.exCB)
    cb.check()

    cb = Callback()
    p.begin_opFloatDouble(3.14, 1.1E10, cb.opFloatDouble, cb.exCB)
    cb.check()

    cb = Callback()
    p.begin_opString("hello", "world", cb.opString, cb.exCB)
    cb.check()

    cb = Callback()
    p.begin_opMyEnum(Test.MyEnum.enum2, cb.opMyEnum, cb.exCB)
    cb.check()

    cb = Callback(communicator)
    p.begin_opMyClass(p, cb.opMyClass, cb.exCB)
    cb.check()

    si1 = Test.Structure()
    si1.p = p
    si1.e = Test.MyEnum.enum3
    si1.s = Test.AnotherStruct()
    si1.s.s = "abc"
    si2 = Test.Structure()
    si2.p = None
    si2.e = Test.MyEnum.enum2
    si2.s = Test.AnotherStruct()
    si2.s.s = "def"

    cb = Callback(communicator)
    p.begin_opStruct(si1, si2, cb.opStruct, cb.exCB)
    cb.check()

    bsi1 = (0x01, 0x11, 0x12, 0x22)
    bsi2 = (0xf1, 0xf2, 0xf3, 0xf4)

    cb = Callback()
    p.begin_opByteS(bsi1, bsi2, cb.opByteS, cb.exCB)
    cb.check()

    bsi1 = (True, True, False)
    bsi2 = (False, )

    cb = Callback()
    p.begin_opBoolS(bsi1, bsi2, cb.opBoolS, cb.exCB)
    cb.check()

    ssi = (1, 2, 3)
    isi = (5, 6, 7, 8)
    lsi = (10, 30, 20)

    cb = Callback()
    p.begin_opShortIntLongS(ssi, isi, lsi, cb.opShortIntLongS, cb.exCB)
    cb.check()

    fsi = (3.14, 1.11)
    dsi = (1.1E10, 1.2E10, 1.3E10)

    cb = Callback()
    p.begin_opFloatDoubleS(fsi, dsi, cb.opFloatDoubleS, cb.exCB)
    cb.check()

    ssi1 = ('abc', 'de', 'fghi')
    ssi2 = ('xyz', )

    cb = Callback()
    p.begin_opStringS(ssi1, ssi2, cb.opStringS, cb.exCB)
    cb.check()

    bsi1 = ((0x01, 0x11, 0x12), (0xff, ))
    bsi2 = ((0x0e, ), (0xf2, 0xf1))

    cb = Callback()
    p.begin_opByteSS(bsi1, bsi2, cb.opByteSS, cb.exCB)
    cb.check()

    fsi = ((3.14, ), (1.11, ), ())
    dsi = ((1.1E10, 1.2E10, 1.3E10), )

    cb = Callback()
    p.begin_opFloatDoubleSS(fsi, dsi, cb.opFloatDoubleSS, cb.exCB)
    cb.check()

    ssi1 = (('abc', ), ('de', 'fghi'))
    ssi2 = ((), (), ('xyz', ))

    cb = Callback()
    p.begin_opStringSS(ssi1, ssi2, cb.opStringSS, cb.exCB)
    cb.check()

    di1 = {10: True, 100: False}
    di2 = {10: True, 11: False, 101: True}

    cb = Callback()
    p.begin_opByteBoolD(di1, di2, cb.opByteBoolD, cb.exCB)
    cb.check()

    di1 = {110: -1, 1100: 123123}
    di2 = {110: -1, 111: -100, 1101: 0}

    cb = Callback()
    p.begin_opShortIntD(di1, di2, cb.opShortIntD, cb.exCB)
    cb.check()

    di1 = {999999110: -1.1, 999999111: 123123.2}
    di2 = {999999110: -1.1, 999999120: -100.4, 999999130: 0.5}

    cb = Callback()
    p.begin_opLongFloatD(di1, di2, cb.opLongFloatD, cb.exCB)
    cb.check()

    di1 = {'foo': 'abc -1.1', 'bar': 'abc 123123.2'}
    di2 = {'foo': 'abc -1.1', 'FOO': 'abc -100.4', 'BAR': 'abc 0.5'}

    cb = Callback()
    p.begin_opStringStringD(di1, di2, cb.opStringStringD, cb.exCB)
    cb.check()

    di1 = {'abc': Test.MyEnum.enum1, '': Test.MyEnum.enum2}
    di2 = {
        'abc': Test.MyEnum.enum1,
        'qwerty': Test.MyEnum.enum3,
        'Hello!!': Test.MyEnum.enum2
    }

    cb = Callback()
    p.begin_opStringMyEnumD(di1, di2, cb.opStringMyEnumD, cb.exCB)
    cb.check()

    di1 = {Test.MyEnum.enum1: 'abc'}
    di2 = {Test.MyEnum.enum2: 'Hello!!', Test.MyEnum.enum3: 'qwerty'}

    cb = Callback()
    p.begin_opMyEnumStringD(di1, di2, cb.opMyEnumStringD, cb.exCB)
    cb.check()

    s11 = Test.MyStruct()
    s11.i = 1
    s11.j = 1
    s12 = Test.MyStruct()
    s12.i = 1
    s12.j = 2
    s22 = Test.MyStruct()
    s22.i = 2
    s22.j = 2
    s23 = Test.MyStruct()
    s23.i = 2
    s23.j = 3
    di1 = {s11: Test.MyEnum.enum1, s12: Test.MyEnum.enum2}
    di2 = {
        s11: Test.MyEnum.enum1,
        s22: Test.MyEnum.enum3,
        s23: Test.MyEnum.enum2
    }

    cb = Callback()
    p.begin_opMyStructMyEnumD(di1, di2, cb.opMyStructMyEnumD, cb.exCB)
    cb.check()

    lengths = (0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000)
    for l in lengths:
        s = []
        for i in range(l):
            s.append(i)
        cb = Callback(l)
        p.begin_opIntS(s, cb.opIntS, cb.exCB)
        cb.check()

    ctx = {'one': 'ONE', 'two': 'TWO', 'three': 'THREE'}

    test(len(p.ice_getContext()) == 0)
    r = p.begin_opContext()
    c = p.end_opContext(r)
    test(c != ctx)

    test(len(p.ice_getContext()) == 0)
    r = p.begin_opContext(_ctx=ctx)
    c = p.end_opContext(r)
    test(c == ctx)

    p2 = Test.MyClassPrx.checkedCast(p.ice_context(ctx))
    test(p2.ice_getContext() == ctx)
    r = p2.begin_opContext()
    c = p2.end_opContext(r)
    test(c == ctx)

    r = p2.begin_opContext(_ctx=ctx)
    c = p2.end_opContext(r)
    test(c == ctx)

    #
    # Test implicit context propagation
    #
    impls = ('Shared', 'PerThread')
    for i in impls:
        initData = Ice.InitializationData()
        initData.properties = communicator.getProperties().clone()
        initData.properties.setProperty('Ice.ImplicitContext', i)
        ic = Ice.initialize(data=initData)

        ctx = {'one': 'ONE', 'two': 'TWO', 'three': 'THREE'}

        p3 = Test.MyClassPrx.uncheckedCast(
            ic.stringToProxy("test:default -p 12010"))

        ic.getImplicitContext().setContext(ctx)
        test(ic.getImplicitContext().getContext() == ctx)
        r = p3.begin_opContext()
        c = p3.end_opContext(r)
        test(c == ctx)

        ic.getImplicitContext().put('zero', 'ZERO')

        ctx = ic.getImplicitContext().getContext()
        r = p3.begin_opContext()
        c = p3.end_opContext(r)
        test(c == ctx)

        prxContext = {'one': 'UN', 'four': 'QUATRE'}

        combined = {}
        combined.update(ctx)
        combined.update(prxContext)
        test(combined['one'] == 'UN')

        p3 = Test.MyClassPrx.uncheckedCast(p3.ice_context(prxContext))
        ic.getImplicitContext().setContext({})
        r = p3.begin_opContext()
        c = p3.end_opContext(r)
        test(c == prxContext)

        ic.getImplicitContext().setContext(ctx)
        r = p3.begin_opContext()
        c = p3.end_opContext(r)
        test(c == combined)

        ic.destroy()

    cb = Callback()
    p.begin_opIdempotent(cb.opIdempotent, cb.exCB)
    cb.check()

    cb = Callback()
    p.begin_opNonmutating(cb.opNonmutating, cb.exCB)
    cb.check()

    derived = Test.MyDerivedClassPrx.checkedCast(p)
    test(derived)
    cb = Callback()
    derived.begin_opDerived(cb.opDerived, cb.exCB)
    cb.check()