Skip to content

Commit

Permalink
Use cleaner failure testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpnova committed Aug 4, 2014
1 parent fe74476 commit 6963d0f
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions cyclone/tests/test_httpclient.py
Expand Up @@ -162,25 +162,15 @@ def test_rpc_request_error(self):
response.code = 200
response.body = escape.json_encode({"error": {"message": "failed"}})
cyclone.httpclient.fetch.return_value = succeed(response)
try:
yield self.client.foo()
except Exception, e:
self.assertEqual(e.message, "failed")
else:
raise Exception("Should raise an error.")
yield self.assertFailure(self.client.foo(), Exception)

@inlineCallbacks
def test_rpc_request_error_old(self):
response = Mock()
response.code = 200
response.body = escape.json_encode({"error": "some error"})
cyclone.httpclient.fetch.return_value = succeed(response)
try:
yield self.client.foo()
except Exception, e:
self.assertEqual(e.message, "some error")
else:
raise Exception("Should raise an error.")
yield self.assertFailure(self.client.foo(), Exception)

@inlineCallbacks
def test_rpc_request_404(self):
Expand All @@ -189,9 +179,4 @@ def test_rpc_request_404(self):
response.phrase = "Not found."
response.body = escape.json_encode({"result": True})
cyclone.httpclient.fetch.return_value = succeed(response)
try:
yield self.client.foo()
except HTTPError, e:
self.assertEqual(e.log_message, "Not found.")
else:
raise Exception("Should raise an error.")
yield self.assertFailure(self.client.foo(), HTTPError)

0 comments on commit 6963d0f

Please sign in to comment.