@patch('requests.get')
    def test_not_found(self, r_get):
        # Verified response from the live API
        r_get.return_value = Mock(
            status_code=404,
            text="The resource you're looking for cannot be found"
        )

        credentials = Mock(base_url="")
        xero = Xero(credentials)

        try:
            xero.contacts.get(id='deadbeef')
            self.fail("Should raise a XeroNotFound.")

        except XeroNotFound as e:
            # Error messages have been extracted
            self.assertEqual(str(e), "The resource you're looking for cannot be found")

            # The response has also been stored
            self.assertEqual(e.response.status_code, 404)
            self.assertEqual(e.response.text, "The resource you're looking for cannot be found")
        except Exception as e:
            self.fail("Should raise a XeroNotFound, not %s" % e)
If you request an object that doesn't exist, a Not Found exception is raised
dataset/ETHPy150Open freakboy3742/pyxero/tests/exceptions.py/ExceptionsTest.test_not_found