我有一个包含类似下面的单元测试的一些Python代码:Python说我传递了太多的参数给我的函数?
class SunCalcTestCases(unittest.TestCase):
"""Tests for `suncalc.py`."""
def near(val1, val2):
return abs(val1 - val2) < (margin or 1E-15)
def test_getPositions(self):
"""Get sun positions correctly"""
sunPos = suncalc.getPosition(self.date, self.lat, self.lng)
az = sunPos["azimuth"]
res = self.near(az, -2.5003175907168385)
但是当我运行此我得到的错误:
Traceback (most recent call last):
File "test.py", line 64, in test_getPositions
res = self.near(az, -2.5003175907168385)
TypeError: near() takes exactly 2 arguments (3 given)
我是新来的Python,所以我很抱歉,如果我的思念这里的东西,但据我可以告诉我,当我调用该函数时,只传递两个参数:self.near(az, -2.5003175907168385)
有谁能告诉我为什么它认为我传递3个参数吗?
'def near(self,val1,val2):' – LittleQ