小编Tai*_*oor的帖子

Python AttributeError:对象在单元测试中没有属性

我有 2 个脚本,第一个是 All_Methods,另一个是 All_Testcases,因为我使用的是单元测试框架,所以我们开始吧。

All_Methods 就像:

class All_Services():
    def abc(self):
        x =1

    def bca(self):
        print "My Name is Taimoor"
        self.abc()

    def cba(self):
        self.bca()
Run Code Online (Sandbox Code Playgroud)

在另一个脚本 All_TestCases 上是这样的:

from All_Methods import All_Services as service

    class All_TestCases(unittest.TestCase):
        def test_1_running_method(self)
            service.cba(self)
Run Code Online (Sandbox Code Playgroud)

异常显示是:

AttributeError: 'All_TestCases' object has no attribute 'bca'
Run Code Online (Sandbox Code Playgroud)

请有人告诉我,我在这里缺少什么?谢谢。

python methods class python-unittest

6
推荐指数
1
解决办法
8541
查看次数

标签 统计

class ×1

methods ×1

python ×1

python-unittest ×1