def test_raise_attribute_error(self): """ should raise AttributeError when trying to access a non-existent method on list and element """ with self.assertRaises(AttributeError): the_list = ElementList([Person(), Person()]) the_list.talk()
def test_attribute_error_content(self): "should raise AttributeError with right content" expected_message = "'ElementList' object has no attribute 'talk'" try: the_list = ElementList([Person(), Person()]) the_list.talk() except AttributeError, e: assert_equals(expected_message, e.message)
def test_attribute_error_content(): "should raise AttributeError with right content" with pytest.raises(AttributeError) as e: the_list = ElementList([Person(), Person()]) the_list.talk() expected_message = "'ElementList' object has no attribute 'talk'" assert expected_message == str(e.value)
def test_attribute_error_content(self): "should raise AttributeError with right content" with self.assertRaises(AttributeError) as cm: the_list = ElementList([Person(), Person()]) the_list.talk() expected_message = "'ElementList' object has no attribute 'talk'" e = cm.exception self.assertEqual(expected_message, e.args[0])