3 This function behaves as a custom TestLoader for python unittests.
5 With no system arguments, the default unittest TestRunner is used.
7 If the first system argument (sys.argv[1]) is set to 'xml', a XMLTestRunner
8 is used, which produces a JUnit compatible XML output file. Within the current
9 module, each function is identified which is a subclass of unittest.TestCase
10 and for each TestCase, a test suite is executed, producing an individual
11 output file for each TestCase. The output file has the name,
12 'PYTEST-<TestCaseName>.xml'.
14 Example of a Python testcase:
16 .. code-block:: python
20 class TestRenumber(unittest.TestCase):
26 def testSomeFunction(self):
30 if __name__ == "__main__":
31 from ost import testutils
38 if len(sys.argv)>1
and sys.argv[1]==
'xml':
42 from ost
import xmlrunner
43 for name, obj
in inspect.getmembers(__main__):
44 if (isinstance(obj, (type, types.ClassType))
and
45 issubclass(obj, unittest.TestCase)):
46 suite = unittest.TestLoader().loadTestsFromTestCase(obj)
47 stream = open(
'PYTEST-%s.xml'%name,
'w')