sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #17455
[Question #226713]: How to create an instance of an inherited class in unittest Python so that I can register the instance of that class in simpleXMLRPCServer
New question #226713 on Sikuli:
https://answers.launchpad.net/sikuli/+question/226713
from __future__ import with_statement
from sikuli.Sikuli import *
import os
import unittest
import this
import xmlrpclib
import SimpleXMLRPCServer, SocketServer, threading
class SimpleThreadedXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer.SimpleXMLRPCServer):
pass
class ABC(object):
def A(self):
...........
def B(self):
...........
def C(self):
...........
class XYZ(unittest.TestCase,ABC):
def setUp(self):
print "Inside setup"
pass
def tearDown(self):
print "Inside tearDown"
pass
def test_1(self):
self.A()
self.B()
self.C()
def D(self):
print "Inside D"
return True
suite = unittest.TestLoader().loadTestsFromTestCase(XYZ)
class ServerThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.server = SimpleThreadedXMLRPCServer(("x.x.x.1", 8000))
#self.server.register_instance() #How to Register an instance of XYZ here.
def run(self):
self.server.serve_forever()
server = ServerThread()
server.start()
My question is how can we Register an instance of XYZ here in the commented line above so that it can be called from the XMLRPC client like:
client = xmlrpclib.ServerProxy("http://x.x.x.2:8000")
handraise = client.D() #Or any other possible way
I hope it might work with register_function(D), but I want the whole class XYZ to be exposed using register_instance().
At present the Error I'm getting at the client side is :
Fault: <Fault 1: "<type 'exceptions.TypeError'>:unbound method D() must be called with XYZ instance as first argument (got nothing instead)">
Thanks
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.