Last change
on this file since 993 was 993, checked in by wouter, 3 months ago |
#338 swapped @Parameters() and @staticmethod to show an issue with this particular order of annotations.
|
File size:
1.5 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 | @Parameters()
|
---|
41 | @staticmethod
|
---|
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 |
|
---|
55 | @RunWith(JUnit4ClassRunner)
|
---|
56 | class Clazz4(Clazz1):
|
---|
57 | @Test(expected=ValueError)
|
---|
58 | def doit(self):
|
---|
59 | raise ValueError("this exception is to be expected")
|
---|
60 |
|
---|
61 |
|
---|
62 |
|
---|
63 | class RunnerTest(unittest.TestCase):
|
---|
64 | def testUsingDefaultRunner(self):
|
---|
65 | runTests(Clazz1)
|
---|
66 |
|
---|
67 | def test2(self):
|
---|
68 | runTests(Clazz2)
|
---|
69 |
|
---|
70 | def testMissingAnnotation(self):
|
---|
71 | self.assertRaises(ValueError, lambda: runTests(MissingParameterAnnotation) )
|
---|
72 |
|
---|
73 | def test4(self):
|
---|
74 | runTests(Clazz4)
|
---|
75 |
|
---|
76 | def test3(self):
|
---|
77 | runTests(Clazz3)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.