Rev | Line | |
---|
[989] | 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.After import After, getAfter
|
---|
| 7 |
|
---|
| 8 |
|
---|
| 9 | class 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 |
|
---|
| 26 | class Clazz2(Clazz1):
|
---|
| 27 | @After()
|
---|
| 28 | def closeit(self):
|
---|
| 29 | return "ok"
|
---|
| 30 |
|
---|
| 31 |
|
---|
| 32 | class 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.