source: unitpy/test/RunWithTest.py@ 1030

Last change on this file since 1030 was 993, checked in by wouter, 5 months ago

#338 swapped @Parameters() and @staticmethod to show an issue with this particular order of annotations.

File size: 1.2 KB
Line 
1import unittest
2import random
3from unitpy.GeneralTests import GeneralTests
4from typing import List
5from pickle import TRUE
6from unitpy.Before import Before, getBefore
7from unitpy.RunWith import RunWith, getRunWith
8from unitpy.Runner import JUnit4ClassRunner, Parameterized
9
10class Clazz1:
11 '''
12 Bugged, it always returns the same hashcode.
13 '''
14 def __init__(self, v:str):
15 self.value = v
16
17 def __repr__(self):
18 return str(self.value) + " " + str(random.randint(1,100))
19
20
21
22 def __hash__(self):
23 return hash(self.value)
24
25 def __eq__(self, other):
26 return isinstance(other, self.__class__) and \
27 self.value == other.value
28
29@RunWith(JUnit4ClassRunner)
30class Clazz2(Clazz1):
31 @Before()
32 def initialize(self):
33 return "ok"
34
35
36
37@RunWith(Parameterized)
38class Clazz3(Clazz1):
39 def initialize(self):
40 return "ok"
41
42
43
44
45class RunWithTest(unittest.TestCase):
46 def test1(self):
47 self.assertEqual(JUnit4ClassRunner, getRunWith(Clazz1))
48
49 def test2(self):
50 self.assertEqual(JUnit4ClassRunner, getRunWith(Clazz2))
51
52 def test3(self):
53 self.assertEqual(Parameterized, getRunWith(Clazz3))
Note: See TracBrowser for help on using the repository browser.