Say I have:
class Calculator():
def divide (self, divident, divisor):
return divident/divisor`
And I want to test its divide method using Python 3.4 unittest
module.
Does my code have to have instantiation of class to be able to test it? Ie, is the setUp
method needed in the following test class:
class TestCalculator(unittest.TestCase):
def setUp(self):
self.calc = src.calculator.Calculator()
def test_divide_by_zero(self):
self.assertRaises(ZeroDivisionError, self.calc(0, 1))
Aucun commentaire:
Enregistrer un commentaire