Last change
on this file since 1269 was 994, checked in by wouter, 5 months ago |
#339 added tests with both annotation orders, to avoid regression bugs
|
File size:
1.8 KB
|
Line | |
---|
1 | import unittest
|
---|
2 | import random
|
---|
3 | from unitpy.GeneralTests import GeneralTests
|
---|
4 | from typing import List
|
---|
5 | from pickle import TRUE
|
---|
6 | from unitpy.Runner import Runner, Parameterized, JUnit4ClassRunner, runTests
|
---|
7 | from unitpy.RunWith import RunWith
|
---|
8 | from unitpy.Parameters import Parameters
|
---|
9 | from unitpy.Test import Test
|
---|
10 |
|
---|
11 | class Clazz1:
|
---|
12 | @Test()
|
---|
13 | def doit(self):
|
---|
14 | print( "ok")
|
---|
15 |
|
---|
16 |
|
---|
17 | @RunWith(JUnit4ClassRunner)
|
---|
18 | class Clazz2(Clazz1):
|
---|
19 | @Test()
|
---|
20 | def doit(self):
|
---|
21 | print( "ok")
|
---|
22 | @Test()
|
---|
23 | def ok2(self):
|
---|
24 | print( "ok2")
|
---|
25 |
|
---|
26 |
|
---|
27 |
|
---|
28 | @RunWith(Parameterized)
|
---|
29 | class MissingParameterAnnotation(Clazz1):
|
---|
30 | def __init__(self, v):
|
---|
31 | self._v=v
|
---|
32 |
|
---|
33 | @Test()
|
---|
34 | def doit(self):
|
---|
35 | print( "ok"+self._v)
|
---|
36 |
|
---|
37 |
|
---|
38 | @RunWith(Parameterized)
|
---|
39 | class Clazz3(Clazz1):
|
---|
40 | @staticmethod
|
---|
41 | @Parameters()
|
---|
42 | def params():
|
---|
43 | return [["3"],["4"]]
|
---|
44 |
|
---|
45 | def __init__(self, v):
|
---|
46 | self._v=v
|
---|
47 |
|
---|
48 | @Test()
|
---|
49 | def doit(self):
|
---|
50 | print( "ok"+self._v)
|
---|
51 |
|
---|
52 |
|
---|
53 |
|
---|
54 | @RunWith(Parameterized)
|
---|
55 | class Clazz5(Clazz1):
|
---|
56 | @Parameters()
|
---|
57 | @staticmethod
|
---|
58 | def params():
|
---|
59 | return [["3"],["4"]]
|
---|
60 |
|
---|
61 | def __init__(self, v):
|
---|
62 | self._v=v
|
---|
63 |
|
---|
64 | @Test()
|
---|
65 | def doit(self):
|
---|
66 | print( "ok"+self._v)
|
---|
67 |
|
---|
68 |
|
---|
69 |
|
---|
70 | @RunWith(JUnit4ClassRunner)
|
---|
71 | class Clazz4(Clazz1):
|
---|
72 | @Test(expected=ValueError)
|
---|
73 | def doit(self):
|
---|
74 | raise ValueError("this exception is to be expected")
|
---|
75 |
|
---|
76 |
|
---|
77 |
|
---|
78 | class RunnerTest(unittest.TestCase):
|
---|
79 | def testUsingDefaultRunner(self):
|
---|
80 | runTests(Clazz1)
|
---|
81 |
|
---|
82 | def test2(self):
|
---|
83 | runTests(Clazz2)
|
---|
84 |
|
---|
85 | def testMissingAnnotation(self):
|
---|
86 | self.assertRaises(ValueError, lambda: runTests(MissingParameterAnnotation) )
|
---|
87 |
|
---|
88 | def test4(self):
|
---|
89 | runTests(Clazz4)
|
---|
90 |
|
---|
91 | def test3(self):
|
---|
92 | runTests(Clazz3)
|
---|
93 |
|
---|
94 | def test5(self):
|
---|
95 | runTests(Clazz5)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.