如果你的名字不能和单位一起工作

2024-09-20 22:52:51 发布

您现在位置:Python中文网/ 问答频道 /正文

运行此代码时:

from unittest import *


class TestSomething(TestCase):

    def test_thing(self):
        assert True


if __name__ == '__main__': main()

我得到属性错误:

^{pr2}$

我在win32上使用python3.7.0b4(v3.7.0b4:eb96c37699,2018年5月2日,19:02:22)[MSC v.1913 64位(AMD64)]。 有人能帮忙吗?在


Tags: 代码fromtestimportselftrueifmain
1条回答
网友
1楼 · 发布于 2024-09-20 22:52:51

我无法解释原因,但如果我像下面这样更新你的代码,它会按预期工作。我只是遵循了文档示例1:1,但是使用了您的类代码。在

import unittest

class TestSomething(unittest.TestCase):
    def test_thing(self):
        assert True


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

输出:

^{pr2}$

相关问题 更多 >

    热门问题