[code=python]
class Calculation:
def __init__(self, A=0, B=1):
factor = gcd( abs(A), abs(B) )
if B < 0:
factor = -factor
self._numA = A // factor
self._denoB = B // factor
def __str__(self):
return str(self._numA) + '/' + str(self._denoB )
# now I have 2 different implementations for __int__"
#either 1:
def __int__(self):
return int(float(self) )
# or 2 is used:
def __int__(self):
return self._numA/self._denoB
[/code]
My question is how can I a write a unit test (__name__='__ma in__') to test for which these two implementations produce different result?
class Calculation:
def __init__(self, A=0, B=1):
factor = gcd( abs(A), abs(B) )
if B < 0:
factor = -factor
self._numA = A // factor
self._denoB = B // factor
def __str__(self):
return str(self._numA) + '/' + str(self._denoB )
# now I have 2 different implementations for __int__"
#either 1:
def __int__(self):
return int(float(self) )
# or 2 is used:
def __int__(self):
return self._numA/self._denoB
[/code]
My question is how can I a write a unit test (__name__='__ma in__') to test for which these two implementations produce different result?
Comment