Python unit tests multiple threads -


i'm testing web application , i've written tests using unittest. there necessary steps authorization, exchanging data being tested , on. want test if works fine more 1 client. i'd call same test every client in seperate thread, gather return codes , print result. question how create such threads in python? (my ad hoc solution in bash spawns multiple python processes)

let's consider example:

import unittest  class test(unittest.testcase):      def setup(self):         pass      def teardown(self):         pass      def testname(self):         pass  if __name__ == "__main__":     unittest.main() 

thread.start_new_thread(unittest.main) #something not work

google around, there number of precanned options. nose seems common one.

otherwise 1 of projects, worked in python 3.3

if __name__ == "__main__":     multiprocessing import process     procs=[]     procs.append(process(target=unittest.main, kwargs={'verbosity':2}))     procs.append(process(target=unittest.main, kwargs={'verbosity':2}))     proc in procs:         proc.start()     proc in procs:         proc.join() 

if want run specific tests, similar above use suites unittest.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -