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.Before import Before, getBefore
|
---|
| 7 |
|
---|
| 8 | class 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 |
|
---|
| 27 | class Clazz2(Clazz1):
|
---|
| 28 | @Before()
|
---|
| 29 | def initialize(self):
|
---|
| 30 | return "ok"
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 | class 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.