python - How to generate reports using HtmlTestRunner for unittests which invlove xml-rpc communication? -
if unittest invlove single xml-rpc requests/response between xmlrpc client/server, works fine , generates report on 1 end if scenario scales more 1 xmlrpc request, report not getting generated.
here goes code snippet template:
on 1 machine abc have,
class abc(): def add(): ....... def subtract(): ....... class machineabctest(unittest.testcase): def test_abc(self): x1 = abc_client.multiply() #method resides in machinexyztest y1 = abc_client.divide() #method resides in machinexyztest suite = unittest.testloader().loadtestsfromtestcase(machineabctest) runner = htmltestrunner.htmltestrunner(stream=fp, verbosity=2) runner.run(suite) class serverthread(threading.thread): def __init__(self): threading.thread.__init__(self) self.abc_server = simplethreadedxmlrpcserver(("xxx.xxx.xxx.1", 8000)) self.abc_server.register_instance(abc()) #methods add & subtract registered def run(self): self.moderator_srv.serve_forever() abc_server = serverthread() abc_server.start()
and on other machine,
class xyz(): def multiply(): ....... def divide(): ....... class machinexyztest(unittest.testcase): def test_xyz(self): x2 = xyz_client.add() #method resides in machinexyztest x2 = xyz_client.subtract() #method resides in machinexyztest suite = unittest.testloader().loadtestsfromtestcase(machinexyztest) runner = htmltestrunner.htmltestrunner(stream=fp, verbosity=2) runner.run(suite) class serverthread(threading.thread): def __init__(self): threading.thread.__init__(self) self.xyz_server = simplethreadedxmlrpcserver(("xxx.xxx.xxx.2", 8000)) self.xyz_server.register_instance(xyz()) # methods multiply & divide registered def run(self): self.xyz_server.serve_forever() xyz_server = serverthread() xyz_server.start()
there's nothing wrong import statement well
import htmltestrunner reload(htmltestrunner) dir = "d:\\test\\abc_xyz_test" fp = file(os.path.join(dir, "testresult.html"), "wb")
which have included in both files.
it have generated report if there 1 call being made abc like
x1 = abc_client.multiply() #method resides in machinexyztest
and xyz_server serving request. in case report generated on client end(here, abc).
the problem occurs if there's 2-way communication occurring 'or' there more 1 request(as seen in above code snippet) being made(from abc xyz or vice-versa) .
thanks.
Comments
Post a Comment