class MyTestCase(unittest.TestCase): def setUp(self): self.calculator = Calculator() def test_calculator_return_sum(self): result = self.calculator.Sum(1, 2) self.assertEqual(3, result) def test_calculator_return_difference(self): result = self.calculator.Difference(2, 3) self.assertEqual(float(-1), float(result)) def test_calculator_return_product(self): result = self.calculator.Product(2, 2) self.assertEqual(4, result) def test_calculator_return_quotient(self): result = self.calculator.Quotient(2, 4) self.assertEqual(0.5, result) def test_calculator_return_root(self): result = self.calculator.Root(169, 2) self.assertEqual(13, result) def test_calculator_return_power(self): result = self.calculator.Power(13, 2) self.assertEqual(169, result) def test_calculator_return_log(self): result = self.calculator.Logarithm(10, 1) self.assertEqual(0, result) #other defs def test_calculator_access_difference_result(self): self.calculator.Difference(3, 2) self.assertEqual(float(1), self.calculator.Result) def test_calculator_access_sum_result(self): self.calculator.Sum(5, 4) self.assertEqual(9, self.calculator.Result) def test_calculator_access_product_result(self): self.calculator.Product(3, 2) self.assertEqual(6, self.calculator.Result) def test_calculator_access_quotient_result(self): self.calculator.Quotient(8, 4) self.assertEqual(2, self.calculator.Result) def test_multiple_calculators(self): calculator1 = Calculator() calculator2 = Calculator() self.calculator.Sum(calculator1.Sum(1, 2), calculator2.Difference(3, 4)) self.assertEqual(2, self.calculator.Result)
class MyTestCase(unittest.TestCase): def setUp(self): self.calculator = Calculator() def test_instantiate_calculator(self): self.assertIsInstance(self.calculator, Calculator) def test_calculator_return_sum(self): result = self.calculator.Sum(1, 2) self.assertEqual(3, result) def test_calculator_return_difference(self): result = self.calculator.Difference(1, 2) self.assertEqual(-1, result) def test_calculator_access_difference_result(self): self.calculator.Difference(1, 2) self.assertEqual(-1, self.calculator.Result) def test_calculator_access_sum_result(self): self.calculator.Sum(1, 2) self.assertEqual(3, self.calculator.Result) def test_multiple_calculators(self): calculator1 = Calculator() calculator2 = Calculator() self.calculator.Sum(calculator1.Sum(1, 2), calculator2.Difference(3, 4)) self.assertEqual(2, self.calculator.Result) def test_calculator_multiply(self): result = self.calculator.Multiply(2, 3) self.assertEqual(6, result) def test_calculator_divide(self): result = self.calculator.Divide(6, 2) self.assertEqual(3, result) def test_calculator_root(self): result = self.calculator.Root(169, 2) self.assertEqual(13, result) def test_calculator_power(self): result = self.calculator.Power(13, 2) self.assertEqual(169, result) def test_calculator_log(self): result = self.calculator.Logarithm(10, 1) self.assertEqual(0, result)
class MyTestCase(unittest.TestCase): def setUp(self): self.calculator = Calculator() def test_instantiate_calculator(self): self.assertIsInstance(self.calculator, Calculator) def test_calculator_return_sum(self): result = self.calculator.Sum(1, 2) self.assertEqual(3, result) def test_calculator_access_sum_result(self): self.calculator.Sum(1, 2) self.assertEqual(3, self.calculator.Result) def test_calculator_return_difference(self): result = self.calculator.Difference(1, 2) self.assertEquals(-1, result) def test_calculator_access_difference_result(self): self.calculator.Difference(1, 2) self.assertEqual(-1, self.calculator.Result) def test_multiple_calculators(self): calculator1 = Calculator() calculator2 = Calculator() self.calculator.Sum(calculator1.Sum(1, 2), calculator2.Difference(3, 4)) self.assertEqual(2, self.calculator.Result) def test_calculator_return_product(self): self.calculator.Product(1, 2) self.assertEquals(2, self.calculator.Result) def test_calculator_return_quotient(self): self.calculator.Quotient(1, 2) self.assertEqual(0.5, self.calculator.Result) def test_calculator_return_root(self): self.calculator.Root(2, 4) self.assertEquals(2, self.calculator.Result) def test_calculator_return_power(self): self.calculator.Power(2, 2) self.assertEquals(4, self.calculator.Result) def test_calculator_return_logarithm(self): self.calculator.Logarithm(2, 8) self.assertEqual(3, self.calculator.Result)
class MyTestCase(unittest.TestCase): def setUp(self): self.calculator = Calculator() def test_instantiate_calculator(self): self.assertIsInstance(self.calculator, Calculator) def test_calculator_return_sum(self): self.assertEqual(3, self.calculator.Sum(1, 2)) def test_calculator_result_access_difference_result(self): self.calculator.Difference(1, 2) self.assertEqual(-1, self.calculator.Result) def test_calculator_result_access_Sum_result(self): self.calculator.Sum(1, 2) self.assertEqual(3, self.calculator.Result) def test_multiple_result_calculator(self): calculator1 = Calculator() calculator2 = Calculator() calculator1.Sum(1, 2) calculator2.Difference(3, 4) self.calculator.Sum(calculator1.Sum(1, 2), calculator2.Difference(3, 4)) self.assertEqual(2, self.calculator.Result) def test_product_result_calculator(self): self.calculator.Product(2, 4) self.assertEqual(8, self.calculator.Result) def test_division_result_calculator(self): self.calculator.Fraction(6, 3) self.assertEqual(2, self.calculator.Result) def test_power_result_calculator(self): self.calculator.Power(2, 3) self.assertEqual(8, self.calculator.Result) def test_root_result_calculator(self): self.calculator.Root(2, 16) self.assertEqual(4, self.calculator.Result) def test_log_result_calculator(self): float(self.calculator.Log(2, 4)) self.assertEqual(2, self.calculator.Result)
class MyTestCase(unittest.TestCase): def setUp(self): self.calculator = Calculator() def test_instantiate_calculator(self): self.assertIsInstance(self.calculator, Calculator) def test_calculator_return_sum(self): result = self.calculator.Sum(1, 2) self.assertEqual(3, result) def test_calculator_access_sum_result(self): self.calculator.Sum(1, 2) self.assertEqual(3, self.calculator.Result) def test_calculator_return_difference(self): result = self.calculator.Difference(1, 2) self.assertEqual(-1, result) def test_calculator_access_difference_result(self): self.calculator.Difference(1, 2) self.assertEqual(-1, self.calculator.Result) def test_calculator_return_product(self): result = self.calculator.Multiplication(1, 2) self.assertEqual(2, result) def test_calculator_access_product_result(self): self.calculator.Multiplication(1, 2) self.assertEqual(2, self.calculator.Result) def test_calculator_divide(self): result = self.calculator.Divide(10, 5) self.assertEqual(2, result) def test_calculator_root(self): result = self.calculator.Root(9) self.assertEqual(3, result) def test_calculator_power(self): result = self.calculator.Power(4, 2) self.assertEqual(16, result) def test_calculator_log(self): result = self.calculator.Logarithm(10, 1) self.assertEqual(0, result)
class MyTestCase(unittest.TestCase): def setUp(self): self.calculator = Calculator() def test_instantiate_calculator(self): self.assertIsInstance(self.calculator, Calculator) def test_calculator_access_sum_result(self): self.calculator.Sum(1, 2) self.assertEqual(3, self.calculator.Result) def test_calculator_access_difference_result(self): self.calculator.Difference(1, 2) self.assertEqual(-1, self.calculator.Result) def test_calculator_access_product_result(self): self.calculator.Product(1, 2) self.assertEqual(2, self.calculator.Result) def test_calculator_access_quotient_result(self): self.calculator.Quotient(4, 2) self.assertEqual(2, self.calculator.Result) def test_calculator_access_power_result(self): self.calculator.Power(4, 2) self.assertEqual(16, self.calculator.Result) def test_calculator_access_root_result(self): self.calculator.Root(9, 2) self.assertEqual(3, self.calculator.Result) def test_calculator_access_log_result(self): self.calculator.Log(2, 8) self.assertEqual(3, self.calculator.Result) def test_multiple_calculators(self): calculator1 = Calculator() calculator2 = Calculator() self.calculator.Sum(calculator1.Sum(1, 2), calculator2.Difference(3, 4)) self.assertEqual(2, self.calculator.Result)
class MyTestCase(unittest.TestCase): def setUp(self): self.calculator = Calculator() def test_instantiate_calculator(self): self.assertIsInstance(self.calculator, Calculator) def test_calculator_return_sum(self): result = self.calculator.Sum(1, 2) self.assertEqual(3, result) def test_calculator_access_sum_result(self): self.calculator.Sum(1, 2) self.assertEqual(3, self.calculator.Result) def test_calculator_return_difference(self): result = self.calculator.Difference(1, 2) self.assertEqual(-1, result) def test_calculator_access_difference_result(self): self.calculator.Difference(1, 2) self.assertEqual(-1, self.calculator.Result) def test_calculator_return_product(self): result = self.calculator.Multiplication(1, 2) self.assertEqual(2, result) def test_calculator_access_product_result(self): self.calculator.Multiplication(1, 2) self.assertEqual(2, self.calculator.Result) def test_calculator_return_quotient(self): result = self.calculator.Division(4, 2) self.assertEqual(2, result) def test_calculator_access_quotient_result(self): self.calculator.Division(4, 2) self.assertEqual(2, self.calculator.Result) def test_calculator_return_power(self): result = self.calculator.Exponentiation(2, 2) self.assertEqual(4, result) def test_calculator_access_power_result(self): self.calculator.Exponentiation(2, 2) self.assertEqual(4, self.calculator.Result) def test_calculator_return_root(self): result = self.calculator.Root(16, 2) self.assertEqual(4, result) def test_calculator_access_root_result(self): self.calculator.Root(16, 2) self.assertEqual(4, self.calculator.Result) def test_calculator_return_logarithm(self): result = self.calculator.logarithm(64, 2) self.assertEqual(6, self.calculator.Result) def test_calculator_access_result(self): self.calculator.logarithm(64, 2) self.assertEqual(6, self.calculator.Result) def test_multiple_calculators(self): calculator1 = Calculator() calculator2 = Calculator() self.calculator.Sum(calculator1.Sum(1, 2), calculator2.Difference(3, 4)) self.assertEqual(2, self.calculator.Result)