Why isn't assertRaises catching my Attribute Error using python unittest?

后端 未结 3 2029
盖世英雄少女心
盖世英雄少女心 2020-12-29 04:06

I\'m trying to run this test: self.assertRaises(AttributeError, branch[0].childrennodes), and branch[0] does not have an attribute childrenno

3条回答
  •  一生所求
    2020-12-29 04:50

    pytest also has a similar decorator:

    from pytest import raises
    
    def test_raising():
        with raises(AttributeError):
            branch[0].childrennodes
    

提交回复
热议问题