import unittest import random from unitpy.GeneralTests import GeneralTests from typing import List from pickle import TRUE from unitpy.Runner import Runner, Parameterized, JUnit4ClassRunner, runTests from unitpy.RunWith import RunWith from unitpy.Parameters import Parameters from unitpy.Test import Test class Clazz1: @Test() def doit(self): print( "ok") @RunWith(JUnit4ClassRunner) class Clazz2(Clazz1): @Test() def doit(self): print( "ok") @Test() def ok2(self): print( "ok2") @RunWith(Parameterized) class MissingParameterAnnotation(Clazz1): def __init__(self, v): self._v=v @Test() def doit(self): print( "ok"+self._v) @RunWith(Parameterized) class Clazz3(Clazz1): @Parameters() @staticmethod def params(): return [["3"],["4"]] def __init__(self, v): self._v=v @Test() def doit(self): print( "ok"+self._v) @RunWith(JUnit4ClassRunner) class Clazz4(Clazz1): @Test(expected=ValueError) def doit(self): raise ValueError("this exception is to be expected") class RunnerTest(unittest.TestCase): def testUsingDefaultRunner(self): runTests(Clazz1) def test2(self): runTests(Clazz2) def testMissingAnnotation(self): self.assertRaises(ValueError, lambda: runTests(MissingParameterAnnotation) ) def test4(self): runTests(Clazz4) def test3(self): runTests(Clazz3)