Line | |
---|
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.Test import Test,getTestNames, getExpected
|
---|
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 | @Test()
|
---|
28 | def sometest(self):
|
---|
29 | return "ok"
|
---|
30 |
|
---|
31 | class Clazz3(Clazz1):
|
---|
32 | @Test(expected=ValueError)
|
---|
33 | def sometest(self):
|
---|
34 | return "ok"
|
---|
35 |
|
---|
36 |
|
---|
37 | class TestTest(unittest.TestCase):
|
---|
38 | def test1(self):
|
---|
39 | self.assertEqual([], getTestNames(Clazz1))
|
---|
40 |
|
---|
41 | def test2(self):
|
---|
42 | self.assertEqual(['sometest'], getTestNames(Clazz2))
|
---|
43 | self.assertEqual(None, getExpected(Clazz2.sometest))
|
---|
44 |
|
---|
45 | def test3(self):
|
---|
46 | self.assertEqual(['sometest'], getTestNames(Clazz3))
|
---|
47 | self.assertEqual(ValueError, getExpected(Clazz3.sometest))
|
---|
48 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.