Last change
on this file since 1014 was 993, checked in by wouter, 5 months ago |
#338 swapped @Parameters() and @staticmethod to show an issue with this particular order of annotations.
|
File size:
1.2 KB
|
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 | from unitpy.RunWith import RunWith, getRunWith
|
---|
| 8 | from unitpy.Runner import JUnit4ClassRunner, Parameterized
|
---|
| 9 |
|
---|
| 10 | class Clazz1:
|
---|
| 11 | '''
|
---|
| 12 | Bugged, it always returns the same hashcode.
|
---|
| 13 | '''
|
---|
| 14 | def __init__(self, v:str):
|
---|
| 15 | self.value = v
|
---|
| 16 |
|
---|
| 17 | def __repr__(self):
|
---|
| 18 | return str(self.value) + " " + str(random.randint(1,100))
|
---|
| 19 |
|
---|
| 20 |
|
---|
| 21 |
|
---|
| 22 | def __hash__(self):
|
---|
| 23 | return hash(self.value)
|
---|
| 24 |
|
---|
| 25 | def __eq__(self, other):
|
---|
| 26 | return isinstance(other, self.__class__) and \
|
---|
| 27 | self.value == other.value
|
---|
| 28 |
|
---|
[993] | 29 | @RunWith(JUnit4ClassRunner)
|
---|
[989] | 30 | class Clazz2(Clazz1):
|
---|
| 31 | @Before()
|
---|
| 32 | def initialize(self):
|
---|
| 33 | return "ok"
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 |
|
---|
[993] | 37 | @RunWith(Parameterized)
|
---|
[989] | 38 | class Clazz3(Clazz1):
|
---|
| 39 | def initialize(self):
|
---|
| 40 | return "ok"
|
---|
| 41 |
|
---|
| 42 |
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | class RunWithTest(unittest.TestCase):
|
---|
| 46 | def test1(self):
|
---|
| 47 | self.assertEqual(JUnit4ClassRunner, getRunWith(Clazz1))
|
---|
| 48 |
|
---|
| 49 | def test2(self):
|
---|
| 50 | self.assertEqual(JUnit4ClassRunner, getRunWith(Clazz2))
|
---|
| 51 |
|
---|
| 52 | def test3(self):
|
---|
| 53 | self.assertEqual(Parameterized, getRunWith(Clazz3))
|
---|
Note:
See
TracBrowser
for help on using the repository browser.