From 890a4fe9ff04e287c0170a29a0c57771fcef8407 Mon Sep 17 00:00:00 2001 From: voith Date: Sun, 25 Sep 2016 20:49:06 +0530 Subject: [PATCH] Fix exception message when creating a response When you register a handler the type for text or data can be a string or a callback that provides a string. By the time you get to create_response this callback should have been called and only a string can be passed. This check originally would have been in place for when a callback was run and the return value was not the expected type, however create_response is a public function that can be used on its own. Correct the exception to clarify in create_response you must pass a string or bytes and not a callback. Change-Id: I3e700afddc1f40454f69a564066495bfc77d91c8 Closes-Bug: #1627506 --- requests_mock/response.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requests_mock/response.py b/requests_mock/response.py index 7d0ba20..9661ed3 100644 --- a/requests_mock/response.py +++ b/requests_mock/response.py @@ -148,9 +148,9 @@ def create_response(request, **kwargs): encoding = None if content and not isinstance(content, six.binary_type): - raise TypeError('Content should be a callback or binary data') + raise TypeError('Content should be binary data') if text and not isinstance(text, six.string_types): - raise TypeError('Text should be a callback or string data') + raise TypeError('Text should be string data') if json is not None: text = jsonutils.dumps(json)