学习unittest遇到问题:AttributeError: 'Users' object has no attribute 'store_full_name'

我照着书上的例题写的,可是看不懂这个报错,为什么会没有store这个属性?我还试着把Users里的full_name改成列表的格式也不可以……

问题相关代码:就是一个检查全名的类
class Users():
    def __init__(self,first_name,last_name):
        self.first_name = first_name
        self.last_name = last_name
        self.full_name = self.first_name.title(),self.last_name.title()
import unittest
class TestUsersName(unittest.TestCase):
    def test_single_name(self):
        meilin = Users('leen','may')
        meilin.store_full_name('MayLeen')
        self.assertEqual('MayLeen',meilin.full_name)
unittest.main()
运行结果及报错内容

对这一行:“meilin.store_full_name('MayLeen')”报错:
AttributeError: 'Users' object has no attribute 'store_full_name'

谢谢回答。

你应该是没抄全,还有一个store_full_name方法没抄,再仔细看看

你把store_full_name放在def()里试一下