python - Running Tests From a Module -


I'm trying to run some unit tests in Python which I believe is a module. I have a directory structure like

  TestSuite.pyUnitets. __int __ Py | TestConvertStringToNumber.py  

testuite.py I have

Import import UnitTest class test site: def __init __ (self): pass print "initialization testing "Suite = Unitt. Testloader () LoadTestForm Module (Unitatest) unittest.TextTestRunner (Verbosity = 1) .Run (Suite)

Which test seeks to fix, but it does not take any tests in TestConvertNumberToString.py In that class, I have a set of tasks starting with 'Test'

What should I do that running Pyro TestSuite.py actually closes all my tests in UnitTests? Here is some code that will run all unit tests in one unit:

Code> #! Import import system OS unit_dir = sys.argv [1] from / usr / bin / env python import import if lane (sys.argv) & gt; 1 more '.' For file name in Os.chdir (unit_dir) suite = unittest.TestSuite () os.listdir ('.'): If filename.endswith ('.py') and filename.startswith ('test_'): modname = filename [: -2] module = __import __ (modname) suite.addTest (unittest.TestLoader (.) LoadStestfrom module (module)) unittest.TextTestRunner (Verbosys = 2) .Run (suite) < P> If you call it testuite.py, you will run it like this:

  testuite.py unit  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -