source: unitpy/test/AfterTest.py@ 1119

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

#336 recovery commit. Untested

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