我正在设置单元测试,当试图调用函数Pt2D
时,我得到错误TypeError: 'Pt2D' object is not callable
。在
在搜索问题时,我在前几页尝试了所有其他的解决方法。这两个程序在不同的文件中,我正在导入第一个类。在
class Pt2D(object):
"""Straightforward 2D point class.
Args:
x (float, optional): The initial x-coordinate. Defaults to 0.
y (float, optional): The initial y-coordinate. Defaults to 0.
"""
def __init__(self, x=0, y=0):
class TestPt2D(TestCase):
def setUp(self):
self.geo = Pt2D()
def tearDown(self):
pass
def test_stuff(self):
y1value = self.geo(0)
y2value = self.geo(1)
ymidvalue = self.geo(0.5)
我希望代码能正常工作,但我无法绕过错误。在
填充您的
__init__
方法:相关问题 更多 >
编程相关推荐