import unittest
import random
from unitpy.GeneralTests import GeneralTests
from typing import List
# import unittest
class ObjectUnderTest2:
    '''
    Bugged, it always returns the same hashcode.
    '''
    def __init__(self, v:str):
        self.value = v

    def __repr__(self):
        return str(self.value) + " " + str(random.randint(1,100))

    def __hash__(self):
        return 31

    def __eq__(self, other):
        return isinstance(other, self.__class__) and \
             self.value == other.value



class GeneralTestTest2(unittest.TestCase, GeneralTests[ObjectUnderTest2]):
    def getGeneralTestData(self) -> List[List[ObjectUnderTest2]] :
        list = []
        list.append([ ObjectUnderTest2("hi"),ObjectUnderTest2("hi")])
        list.append([ ObjectUnderTest2("ha")])
        list.append([ ObjectUnderTest2("")])
        list.append([ ObjectUnderTest2(None)]) #type:ignore

        return list;

    def getGeneralTestStrings(self) ->List[str] :
        return ["hi .*", "ha .*", ".*", "None.*"]

    #override
    def testNotEqualsAllData(self):
        sup=super()
        self.assertRaises(AssertionError, lambda:sup.testNotEqualsAllData())
        #,"are different but actually have same hashcode");


