コード例 #1
0
 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()
コード例 #2
0
 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()
コード例 #3
0
 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)
コード例 #4
0
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)
コード例 #5
0
 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)
コード例 #6
0
    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])
コード例 #7
0
    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])