mercredi 31 août 2016

TypeError: assertEqual() takes at least 3 arguments (2 given)

I am using python 2.7.6, still my program shows an error.

import assignment3 as a3
import unittest
import numpy as np


class a3Testcase(unittest.TestCase):
    """Test for a3 functions"""
    def func_const(self, x):
        return 1

    def func_linear(self, x):
        return x

    def func_quad(self, x):
        return x**2

    def test_gamma_calc(self):
        """determine the Gamma from gamma distribution
        a to b"""
        self.assertAlmostEqual(a3.gamma_calc(self.func_linear, 0, 2), 2)
        self.assertAlmostEqual(a3.gamma_calc(self.func_quad, 0, 1), 1.0/3)

    # def test_create_vortices(self):
    #     """"""
    #     pass

    def test_cal_gamma_array(self):
        """Find the Gamma at mid point of panels a given gamma distribution"""
        panel_coordinates = np.linspace(0, 1, 1+1)
        self.assertEqual((
            a3.calc_gamma_array(panel_coordinates, self.func_const),
            np.array([1.0])))

if __name__ == '__main__':
    unittest.main()

Traceback (most recent call last):

Result:

File "test_assignment3.py", line 32, in test_cal_gamma_array
    np.array([1.0])))

TypeError: assertEqual() takes at least 3 arguments (2 given)

----------------------------------------------------------------------
Ran 2 tests in 0.000s

FAILED (errors=1)

Aucun commentaire:

Enregistrer un commentaire