Python nosetests的范例文档里有个unittest函数,里面的self.assert-(1 == 1)的意

学习 时间:2026-04-03 12:52:49 阅读:6550
Python nosetests的范例文档里有个unittest函数,里面的self.assert_(1 == 1)的意思?其实意思我明白,但是有这个语法吗?我只知道assert 1==1,程序如下:###### the standard unittest-derived test###import unittestclass ExampleTest(unittest.TestCase):def test_a(self):self.assert_(1 == 1) ###### an unparented test -- no encapsulating class,just any fn starting with### 'test'.###def test_b():"""Raw,unparented test."""assert 'b' == 'b'###### non-unittest derived test -- class is instantiated,then functions### starting with 'test' are executed.###class TestExampleTwo:def test_c(self):assert 'c' == 'c'

最佳回答

追寻的硬币

震动的发卡

2026-04-03 12:52:49

assert_() 方法的定义可能是在unittest。TestCase里。你找一下unittest。TestCase这个类的定义看看

最新回答共有2条回答

  • 心灵美的纸鹤
    回复
    2026-04-03 12:52:49

    assert_() 方法的定义可能是在unittest。TestCase里。你找一下unittest。TestCase这个类的定义看看

上一篇 亚洲面积占地球总面积的几分之几

下一篇 谁能帮我找一篇,仿写六年级《山中访友》的作文?