class TestException(TestCase): def setUp(self): from qiita.client import Client self.client = Client() @patch('qiita.client.requests.get') def test_should_raise_not_found_exception(self, m): """ NotFound Error should be raised if user not exists. """ from qiita.exceptions import NotFoundError dummy_error_response(m, 404) # with self.assertRaises() plays with Python2.7+ try: self.client.get('/users/foobar') self.fail() except NotFoundError: self.assertTrue(True) except Exception: self.fail()