sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #17852
Re: [Question #228125]: How to generate reports using HtmlTestRunner for unittests which involve xml-rpc communication?
Question #228125 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/228125
Status: Answered => Open
Aravind is still having a problem:
Ok.. understood.
I hope calling that displayABC is what you meant by "some communication
between the scheduled handlers and the clients on the same machine". If
so, Yes I need that communication on the same machine.
And can you please check out the following code snippet that I had been trying to run:
On Machine 1:
import math
import filecmp
import xmlrpclib
import os
import unittest
import SimpleXMLRPCServer, threading, SocketServer
from shutil import copyfile
import HTMLTestRunner
reload(HTMLTestRunner)
dir = "D:\MyWorkSpace\DellReportTest"
fp = file(os.path.join(dir, "TestResultDell.html"), "wb")
class SimpleThreadedXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer.SimpleXMLRPCServer):
pass
class ABC():
def displayABC(self):
print "Inside Display ABC"
def add(self):
print "inside add"
return True
def subtract(self):
print "inside subtract"
return True
class ServerThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.abc_server = SimpleThreadedXMLRPCServer(("x.x.x.2", 8000))
self.abc_server.register_instance(ABC()) #methods add & subtract will get registered
def run(self):
self.abc_server.serve_forever()
abc_server = ServerThread()
abc_server.start()
abc_client = xmlrpclib.ServerProxy("http://x.x.x.1:8000")
class MachineABCTest(unittest.TestCase):
def setUp(self):
pass
def test_ABC(self):
abc = ABC()
abc.displayABC()
x1 = abc_client.multiply() #method which resides in MachineXYZTest
y1 = abc_client.divide() #method which resides in MachineXYZTest
def tearDown(self):
pass
suite = unittest.TestLoader().loadTestsFromTestCase(MachineABCTest)
runner = HTMLTestRunner.HTMLTestRunner(stream=fp, verbosity=2)
runner.run(suite)
On Machine 2:
from sikuli.Sikuli import *
import math
import filecmp
import xmlrpclib
import os
import unittest
import SimpleXMLRPCServer, threading, SocketServer
from shutil import copyfile
import HTMLTestRunner
reload(HTMLTestRunner)
dir = "D:\MyWorkSpace\HpReportTest"
fp = file(os.path.join(dir, "TestResultHp.html"), "wb")
class SimpleThreadedXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer.SimpleXMLRPCServer):
pass
class XYZ():
def displayXYZ(self):
print "Inside Display XYZ"
def multiply(self):
print "inside multiply"
return True
def divide(self):
print "inside divide"
return True
class ServerThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.xyz_server = SimpleThreadedXMLRPCServer(("x.x.x.1", 8000))
self.xyz_server.register_instance(XYZ()) # methods multiply & divide will get registered
def run(self):
self.xyz_server.serve_forever()
xyz_server = ServerThread()
xyz_server.start()
xyz_client = xmlrpclib.ServerProxy("http://x.x.x.2:8000")
class MachineXYZTest(unittest.TestCase):
def setUp(self):
pass
def test_XYZ(self):
xyz = XYZ()
xyz.displayXYZ()
x1 = xyz_client.add() #method which resides in MachineXYZTest
y1 = xyz_client.subtract() #method which resides in MachineXYZTest
def tearDown(self):
pass
suite = unittest.TestLoader().loadTestsFromTestCase(MachineXYZTest)
runner = HTMLTestRunner.HTMLTestRunner(stream=fp, verbosity=2)
runner.run(suite)
So that I can get to know whether the HTMLTesRunner is getting reset
anywhere. Thanks a lot !
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.