source: unitpy/test/BeforeTest.py@ 1404

Last change on this file since 1404 was 989, checked in by wouter, 5 months ago

#336 recovery commit. Untested

File size: 861 bytes
RevLine 
[989]1import unittest
2import random
3from unitpy.GeneralTests import GeneralTests
4from typing import List
5from pickle import TRUE
6from unitpy.Before import Before, getBefore
7
8class Clazz1:
9 '''
10 Bugged, it always returns the same hashcode.
11 '''
12 def __init__(self, v:str):
13 self.value = v
14
15 def __repr__(self):
16 return str(self.value) + " " + str(random.randint(1,100))
17
18
19
20 def __hash__(self):
21 return hash(self.value)
22
23 def __eq__(self, other):
24 return isinstance(other, self.__class__) and \
25 self.value == other.value
26
27class Clazz2(Clazz1):
28 @Before()
29 def initialize(self):
30 return "ok"
31
32
33class BeforeTest(unittest.TestCase):
34 def test1(self):
35 self.assertEqual(None, getBefore(Clazz1))
36
37 def test2(self):
38 self.assertEqual(Clazz2.initialize, getBefore(Clazz2))
Note: See TracBrowser for help on using the repository browser.