def test_3d_matrix(self, mock_cof): self.mock_width.return_value = 3 mock_cof.side_effect = [16, -23, 42] matrix = Matrix([4, -3, 1], [2, -1, 2], [1, 5, 7]) self.assertEqual(matrix.determinant(), 175) mock_cof.assert_any_call(0, 0) mock_cof.assert_any_call(0, 1) mock_cof.assert_any_call(0, 2)
def test_2d_matrix(self): self.mock_width.return_value = 2 matrix = Matrix([1, 2], [3, 4]) self.assertEqual(matrix.determinant(), -2)
def test_matrix_must_be_square(self): matrix = Matrix([1, 2], [3, 4]) self.mock_square.return_value = False with self.assertRaises(ValueError): matrix.determinant()