diff options
Diffstat (limited to 'python/test/Ice/blobject/Client.py')
-rwxr-xr-x | python/test/Ice/blobject/Client.py | 96 |
1 files changed, 42 insertions, 54 deletions
diff --git a/python/test/Ice/blobject/Client.py b/python/test/Ice/blobject/Client.py index f118721e20b..64846c2702f 100755 --- a/python/test/Ice/blobject/Client.py +++ b/python/test/Ice/blobject/Client.py @@ -8,75 +8,63 @@ # # ********************************************************************** -import os, sys, traceback - +from TestHelper import TestHelper +TestHelper.loadSlice('Test.ice') +import sys import Ice -Ice.loadSlice('Test.ice') import Test import RouterI + def test(b): if not b: raise RuntimeError('test assertion failed') -def run(args, communicator, sync): - hello = Test.HelloPrx.checkedCast(communicator.stringToProxy("test:default -p 12010")) - hello.sayHello(False) - hello.sayHello(False, { "_fwd":"o" } ) - test(hello.add(10, 20) == 30) - try: - hello.raiseUE() - test(False) - except Test.UE: - pass - try: - Test.HelloPrx.checkedCast(communicator.stringToProxy("unknown:default -p 12010 -t 10000")) - test(False) - except Ice.ObjectNotExistException: - pass +class Client(TestHelper): + + def allTests(self, communicator, sync): + hello = Test.HelloPrx.checkedCast(communicator.stringToProxy("test:default -p 12010")) + hello.sayHello(False) + hello.sayHello(False, {"_fwd": "o"}) + test(hello.add(10, 20) == 30) + try: + hello.raiseUE() + test(False) + except Test.UE: + pass + + try: + Test.HelloPrx.checkedCast(communicator.stringToProxy("unknown:default -p 12010 -t 10000")) + test(False) + except Ice.ObjectNotExistException: + pass - # First try an object at a non-existent endpoint. - try: - Test.HelloPrx.checkedCast(communicator.stringToProxy("missing:default -p 12000 -t 10000")) - test(False) - except Ice.UnknownLocalException as e: - test(e.unknown.find('ConnectionRefusedException')) - if sync: - hello.shutdown() - return True + # First try an object at a non-existent endpoint. + try: + Test.HelloPrx.checkedCast(communicator.stringToProxy("missing:default -p 12000 -t 10000")) + test(False) + except Ice.UnknownLocalException as e: + test(e.unknown.find('ConnectionRefusedException')) + if sync: + hello.shutdown() -argv = sys.argv[:] # Clone the arguments to use again later + def run(self, args): -try: - initData = Ice.InitializationData() - initData.properties = Ice.createProperties(argv) - initData.properties.setProperty('Ice.Warn.Dispatch', '0') - with Ice.initialize(argv, initData) as communicator: - router = RouterI.RouterI(communicator, False) - sys.stdout.write("testing async blobject... ") - sys.stdout.flush() - status = run(sys.argv, communicator, False) - print("ok") - router.destroy() -except: - traceback.print_exc() - status = False + properties = self.createTestProperties(args) + properties.setProperty('Ice.Warn.Dispatch', '0') + with self.initialize(properties=properties) as communicator: + router = RouterI.RouterI(communicator, False) + sys.stdout.write("testing async blobject... ") + sys.stdout.flush() + self.allTests(communicator, False) + print("ok") + router.destroy() -if status: - try: - initData = Ice.InitializationData() - initData.properties = Ice.createProperties(sys.argv) - initData.properties.setProperty('Ice.Warn.Dispatch', '0') - with Ice.initialize(sys.argv, initData) as communicator: + with self.initialize(properties=properties) as communicator: router = RouterI.RouterI(communicator, True) sys.stdout.write("testing sync blobject... ") sys.stdout.flush() - status = run(sys.argv, communicator, True) + self.allTests(communicator, True) print("ok") router.destroy() - except: - traceback.print_exc() - status = False - -sys.exit(not status) |