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

学习 时间:2026-05-30 18:50:20 阅读:734
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-05-30 18:50:20

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

最新回答共有2条回答

  • 甜美的铃铛
    回复
    2026-05-30 18:50:20

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

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

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