diff --git a/httpretty/core.py b/httpretty/core.py index 3d478b0..8c9b2a0 100644 --- a/httpretty/core.py +++ b/httpretty/core.py @@ -163,14 +163,14 @@ class fakesock(object): ), 'subject': ( ( - ('organizationName', u'*.%s' % self._host), + ('organizationName', '*.%s' % self._host), ), ( ('organizationalUnitName', - u'Domain Control Validated'), + 'Domain Control Validated'), ), ( - ('commonName', u'*.%s' % self._host), + ('commonName', '*.%s' % self._host), ), ), } @@ -630,7 +630,7 @@ class URIMatcher(object): class httpretty(HttpBaseClass): - u"""The URI registration class""" + """The URI registration class""" _entries = {} latest_requests = [] @@ -683,7 +683,7 @@ class httpretty(HttpBaseClass): cls._entries[matcher] = entries_for_this_uri def __str__(self): - return u'' % len(self._entries) + return '' % len(self._entries) @classmethod def Response(cls, body, method=None, uri=None, adding_headers=None, forcing_headers=None, diff --git a/setup.py b/setup.py index d94aaa7..09f7ca2 100755 --- a/setup.py +++ b/setup.py @@ -53,7 +53,7 @@ def test_packages(): setup(name='httpretty', version=version, description='HTTP client mock for Python', - author=u'Gabriel Falcao', + author='Gabriel Falcao', author_email='gabriel@nacaolivre.org', url='http://github.com/gabrielfalcao/httpretty', packages=get_packages(), diff --git a/tests/functional/test_bypass.py b/tests/functional/test_bypass.py index f960c1d..e5704fb 100644 --- a/tests/functional/test_bypass.py +++ b/tests/functional/test_bypass.py @@ -64,7 +64,7 @@ def stop_tcp_server(context): @httpretty.activate @that_with_context(start_http_server, stop_http_server) def test_httpretty_bypasses_when_disabled(context): - u"httpretty should bypass all requests by disabling it" + "httpretty should bypass all requests by disabling it" httpretty.register_uri( httpretty.GET, "http://localhost:9999/go-for-bubbles/", @@ -97,7 +97,7 @@ def test_httpretty_bypasses_when_disabled(context): @httpretty.activate @that_with_context(start_http_server, stop_http_server) def test_httpretty_bypasses_a_unregistered_request(context): - u"httpretty should bypass a unregistered request by disabling it" + "httpretty should bypass a unregistered request by disabling it" httpretty.register_uri( httpretty.GET, "http://localhost:9999/go-for-bubbles/", @@ -119,7 +119,7 @@ def test_httpretty_bypasses_a_unregistered_request(context): @httpretty.activate @that_with_context(start_tcp_server, stop_tcp_server) def test_using_httpretty_with_other_tcp_protocols(context): - u"httpretty should work even when testing code that also use other TCP-based protocols" + "httpretty should work even when testing code that also use other TCP-based protocols" httpretty.register_uri( httpretty.GET, "http://falcao.it/foo/", diff --git a/tests/functional/test_debug.py b/tests/functional/test_debug.py index 2f2f23e..9872530 100644 --- a/tests/functional/test_debug.py +++ b/tests/functional/test_debug.py @@ -41,7 +41,7 @@ def create_socket(context): @httprettified @scenario(create_socket) def test_httpretty_debugs_socket_send(context): - u"HTTPretty should debug socket.send" + "HTTPretty should debug socket.send" expect(context.sock.send).when.called.to.throw( RuntimeError, @@ -52,7 +52,7 @@ def test_httpretty_debugs_socket_send(context): @httprettified @scenario(create_socket) def test_httpretty_debugs_socket_sendto(context): - u"HTTPretty should debug socket.sendto" + "HTTPretty should debug socket.sendto" expect(context.sock.sendto).when.called.to.throw( RuntimeError, @@ -63,7 +63,7 @@ def test_httpretty_debugs_socket_sendto(context): @httprettified @scenario(create_socket) def test_httpretty_debugs_socket_recv(context): - u"HTTPretty should debug socket.recv" + "HTTPretty should debug socket.recv" expect(context.sock.recv).when.called.to.throw( RuntimeError, @@ -74,7 +74,7 @@ def test_httpretty_debugs_socket_recv(context): @httprettified @scenario(create_socket) def test_httpretty_debugs_socket_recvfrom(context): - u"HTTPretty should debug socket.recvfrom" + "HTTPretty should debug socket.recvfrom" expect(context.sock.recvfrom).when.called.to.throw( RuntimeError, @@ -85,7 +85,7 @@ def test_httpretty_debugs_socket_recvfrom(context): @httprettified @scenario(create_socket) def test_httpretty_debugs_socket_recv_into(context): - u"HTTPretty should debug socket.recv_into" + "HTTPretty should debug socket.recv_into" expect(context.sock.recv_into).when.called.to.throw( RuntimeError, @@ -96,7 +96,7 @@ def test_httpretty_debugs_socket_recv_into(context): @httprettified @scenario(create_socket) def test_httpretty_debugs_socket_recvfrom_into(context): - u"HTTPretty should debug socket.recvfrom_into" + "HTTPretty should debug socket.recvfrom_into" expect(context.sock.recvfrom_into).when.called.to.throw( RuntimeError, diff --git a/tests/functional/test_httplib2.py b/tests/functional/test_httplib2.py index f4464f8..a13801a 100644 --- a/tests/functional/test_httplib2.py +++ b/tests/functional/test_httplib2.py @@ -36,7 +36,7 @@ from httpretty.core import decode_utf8 @httprettified @within(two=microseconds) def test_httpretty_should_mock_a_simple_get_with_httplib2_read(now): - u"HTTPretty should mock a simple GET with httplib2.context.http" + "HTTPretty should mock a simple GET with httplib2.context.http" HTTPretty.register_uri(HTTPretty.GET, "http://yipit.com/", body="Find the best daily deals") @@ -51,7 +51,7 @@ def test_httpretty_should_mock_a_simple_get_with_httplib2_read(now): @httprettified @within(two=microseconds) def test_httpretty_provides_easy_access_to_querystrings(now): - u"HTTPretty should provide an easy access to the querystring" + "HTTPretty should provide an easy access to the querystring" HTTPretty.register_uri(HTTPretty.GET, "http://yipit.com/", body="Find the best daily deals") @@ -67,7 +67,7 @@ def test_httpretty_provides_easy_access_to_querystrings(now): @httprettified @within(two=microseconds) def test_httpretty_should_mock_headers_httplib2(now): - u"HTTPretty should mock basic headers with httplib2" + "HTTPretty should mock basic headers with httplib2" HTTPretty.register_uri(HTTPretty.GET, "http://github.com/", body="this is supposed to be the response", @@ -88,7 +88,7 @@ def test_httpretty_should_mock_headers_httplib2(now): @httprettified @within(two=microseconds) def test_httpretty_should_allow_adding_and_overwritting_httplib2(now): - u"HTTPretty should allow adding and overwritting headers with httplib2" + "HTTPretty should allow adding and overwritting headers with httplib2" HTTPretty.register_uri(HTTPretty.GET, "http://github.com/foo", body="this is supposed to be the response", @@ -114,7 +114,7 @@ def test_httpretty_should_allow_adding_and_overwritting_httplib2(now): @httprettified @within(two=microseconds) def test_httpretty_should_allow_forcing_headers_httplib2(now): - u"HTTPretty should allow forcing headers with httplib2" + "HTTPretty should allow forcing headers with httplib2" HTTPretty.register_uri(HTTPretty.GET, "http://github.com/foo", body="this is supposed to be the response", @@ -138,7 +138,7 @@ def test_httpretty_should_allow_forcing_headers_httplib2(now): @httprettified @within(two=microseconds) def test_httpretty_should_allow_adding_and_overwritting_by_kwargs_u2(now): - u"HTTPretty should allow adding and overwritting headers by keyword args " \ + "HTTPretty should allow adding and overwritting headers by keyword args " \ "with httplib2" HTTPretty.register_uri(HTTPretty.GET, "http://github.com/foo", @@ -167,7 +167,7 @@ def test_httpretty_should_allow_adding_and_overwritting_by_kwargs_u2(now): @httprettified @within(two=microseconds) def test_rotating_responses_with_httplib2(now): - u"HTTPretty should support rotating responses with httplib2" + "HTTPretty should support rotating responses with httplib2" HTTPretty.register_uri( HTTPretty.GET, "https://api.yahoo.com/test", @@ -198,7 +198,7 @@ def test_rotating_responses_with_httplib2(now): @httprettified @within(two=microseconds) def test_can_inspect_last_request(now): - u"HTTPretty.last_request is a mimetools.Message request from last match" + "HTTPretty.last_request is a mimetools.Message request from last match" HTTPretty.register_uri(HTTPretty.POST, "http://api.github.com/", body='{"repositories": ["HTTPretty", "lettuce"]}') @@ -224,7 +224,7 @@ def test_can_inspect_last_request(now): @httprettified @within(two=microseconds) def test_can_inspect_last_request_with_ssl(now): - u"HTTPretty.last_request is recorded even when mocking 'https' (SSL)" + "HTTPretty.last_request is recorded even when mocking 'https' (SSL)" HTTPretty.register_uri(HTTPretty.POST, "https://secure.github.com/", body='{"repositories": ["HTTPretty", "lettuce"]}') @@ -250,7 +250,7 @@ def test_can_inspect_last_request_with_ssl(now): @httprettified @within(two=microseconds) def test_httpretty_ignores_querystrings_from_registered_uri(now): - u"Registering URIs with query string cause them to be ignored" + "Registering URIs with query string cause them to be ignored" HTTPretty.register_uri(HTTPretty.GET, "http://yipit.com/?id=123", body="Find the best daily deals") @@ -292,7 +292,7 @@ def test_callback_response(now): @httprettified def test_httpretty_should_allow_registering_regexes(): - u"HTTPretty should allow registering regexes with httplib2" + "HTTPretty should allow registering regexes with httplib2" HTTPretty.register_uri( HTTPretty.GET, diff --git a/tests/functional/test_requests.py b/tests/functional/test_requests.py index f1dc99d..11b43c6 100644 --- a/tests/functional/test_requests.py +++ b/tests/functional/test_requests.py @@ -50,7 +50,7 @@ next = advance_iterator @httprettified @within(two=microseconds) def test_httpretty_should_mock_a_simple_get_with_requests_read(now): - u"HTTPretty should mock a simple GET with requests.get" + "HTTPretty should mock a simple GET with requests.get" HTTPretty.register_uri(HTTPretty.GET, "http://yipit.com/", body="Find the best daily deals") @@ -64,7 +64,7 @@ def test_httpretty_should_mock_a_simple_get_with_requests_read(now): @httprettified @within(two=microseconds) def test_httpretty_provides_easy_access_to_querystrings(now): - u"HTTPretty should provide an easy access to the querystring" + "HTTPretty should provide an easy access to the querystring" HTTPretty.register_uri(HTTPretty.GET, "http://yipit.com/", body="Find the best daily deals") @@ -79,7 +79,7 @@ def test_httpretty_provides_easy_access_to_querystrings(now): @httprettified @within(two=microseconds) def test_httpretty_should_mock_headers_requests(now): - u"HTTPretty should mock basic headers with requests" + "HTTPretty should mock basic headers with requests" HTTPretty.register_uri(HTTPretty.GET, "http://github.com/", body="this is supposed to be the response", @@ -101,7 +101,7 @@ def test_httpretty_should_mock_headers_requests(now): @httprettified @within(two=microseconds) def test_httpretty_should_allow_adding_and_overwritting_requests(now): - u"HTTPretty should allow adding and overwritting headers with requests" + "HTTPretty should allow adding and overwritting headers with requests" HTTPretty.register_uri(HTTPretty.GET, "http://github.com/foo", body="this is supposed to be the response", @@ -126,7 +126,7 @@ def test_httpretty_should_allow_adding_and_overwritting_requests(now): @httprettified @within(two=microseconds) def test_httpretty_should_allow_forcing_headers_requests(now): - u"HTTPretty should allow forcing headers with requests" + "HTTPretty should allow forcing headers with requests" HTTPretty.register_uri(HTTPretty.GET, "http://github.com/foo", body="", @@ -146,7 +146,7 @@ def test_httpretty_should_allow_forcing_headers_requests(now): @httprettified @within(two=microseconds) def test_httpretty_should_allow_adding_and_overwritting_by_kwargs_u2(now): - u"HTTPretty should allow adding and overwritting headers by keyword args " \ + "HTTPretty should allow adding and overwritting headers by keyword args " \ "with requests" HTTPretty.register_uri(HTTPretty.GET, "http://github.com/foo", @@ -170,7 +170,7 @@ def test_httpretty_should_allow_adding_and_overwritting_by_kwargs_u2(now): @httprettified @within(two=microseconds) def test_rotating_responses_with_requests(now): - u"HTTPretty should support rotating responses with requests" + "HTTPretty should support rotating responses with requests" HTTPretty.register_uri( HTTPretty.GET, "https://api.yahoo.com/test", @@ -201,7 +201,7 @@ def test_rotating_responses_with_requests(now): @httprettified @within(two=microseconds) def test_can_inspect_last_request(now): - u"HTTPretty.last_request is a mimetools.Message request from last match" + "HTTPretty.last_request is a mimetools.Message request from last match" HTTPretty.register_uri(HTTPretty.POST, "http://api.github.com/", body='{"repositories": ["HTTPretty", "lettuce"]}') @@ -227,7 +227,7 @@ def test_can_inspect_last_request(now): @httprettified @within(two=microseconds) def test_can_inspect_last_request_with_ssl(now): - u"HTTPretty.last_request is recorded even when mocking 'https' (SSL)" + "HTTPretty.last_request is recorded even when mocking 'https' (SSL)" HTTPretty.register_uri(HTTPretty.POST, "https://secure.github.com/", body='{"repositories": ["HTTPretty", "lettuce"]}') @@ -253,7 +253,7 @@ def test_can_inspect_last_request_with_ssl(now): @httprettified @within(two=microseconds) def test_httpretty_ignores_querystrings_from_registered_uri(now): - u"HTTPretty should ignore querystrings from the registered uri (requests library)" + "HTTPretty should ignore querystrings from the registered uri (requests library)" HTTPretty.register_uri(HTTPretty.GET, "http://yipit.com/?id=123", body=b"Find the best daily deals") @@ -470,7 +470,7 @@ def test_callback_setting_headers_and_status_response(now): @httprettified def test_httpretty_should_allow_registering_regexes_and_give_a_proper_match_to_the_callback(): - u"HTTPretty should allow registering regexes with requests and giva a proper match to the callback" + "HTTPretty should allow registering regexes with requests and giva a proper match to the callback" HTTPretty.register_uri( HTTPretty.GET, @@ -486,7 +486,7 @@ def test_httpretty_should_allow_registering_regexes_and_give_a_proper_match_to_t @httprettified def test_httpretty_should_allow_registering_regexes(): - u"HTTPretty should allow registering regexes with requests" + "HTTPretty should allow registering regexes with requests" HTTPretty.register_uri( HTTPretty.GET, @@ -503,7 +503,7 @@ def test_httpretty_should_allow_registering_regexes(): @httprettified def test_httpretty_provides_easy_access_to_querystrings_with_regexes(): - u"HTTPretty should match regexes even if they have a different querystring" + "HTTPretty should match regexes even if they have a different querystring" HTTPretty.register_uri( HTTPretty.GET, @@ -521,7 +521,7 @@ def test_httpretty_provides_easy_access_to_querystrings_with_regexes(): @httprettified def test_httpretty_should_allow_multiple_methods_for_the_same_uri(): - u"HTTPretty should allow registering multiple methods for the same uri" + "HTTPretty should allow registering multiple methods for the same uri" url = 'http://test.com/test' methods = ['GET', 'POST', 'PUT'] @@ -546,7 +546,7 @@ def my_callback(request, url, headers): @httprettified def test_httpretty_should_allow_registering_regexes_with_streaming_responses(): - u"HTTPretty should allow registering regexes with requests" + "HTTPretty should allow registering regexes with requests" HTTPretty.register_uri( HTTPretty.POST, @@ -576,7 +576,7 @@ def test_httpretty_should_allow_registering_regexes_with_streaming_responses(): @httprettified def test_httpretty_should_allow_multiple_responses_with_multiple_methods(): - u"HTTPretty should allow multiple responses when binding multiple methods to the same uri" + "HTTPretty should allow multiple responses when binding multiple methods to the same uri" url = 'http://test.com/list' @@ -608,7 +608,7 @@ def test_httpretty_should_allow_multiple_responses_with_multiple_methods(): @httprettified def test_httpretty_should_normalize_url_patching(): - u"HTTPretty should normalize all url patching" + "HTTPretty should normalize all url patching" HTTPretty.register_uri( HTTPretty.GET, diff --git a/tests/functional/test_urllib2.py b/tests/functional/test_urllib2.py index 4994d3c..5e4647a 100644 --- a/tests/functional/test_urllib2.py +++ b/tests/functional/test_urllib2.py @@ -41,7 +41,7 @@ from httpretty.core import decode_utf8 @httprettified @within(two=microseconds) def test_httpretty_should_mock_a_simple_get_with_urllib2_read(): - u"HTTPretty should mock a simple GET with urllib2.read()" + "HTTPretty should mock a simple GET with urllib2.read()" HTTPretty.register_uri(HTTPretty.GET, "http://yipit.com/", body="Find the best daily deals") @@ -56,7 +56,7 @@ def test_httpretty_should_mock_a_simple_get_with_urllib2_read(): @httprettified @within(two=microseconds) def test_httpretty_provides_easy_access_to_querystrings(now): - u"HTTPretty should provide an easy access to the querystring" + "HTTPretty should provide an easy access to the querystring" HTTPretty.register_uri(HTTPretty.GET, "http://yipit.com/", body="Find the best daily deals") @@ -74,7 +74,7 @@ def test_httpretty_provides_easy_access_to_querystrings(now): @httprettified @within(two=microseconds) def test_httpretty_should_mock_headers_urllib2(now): - u"HTTPretty should mock basic headers with urllib2" + "HTTPretty should mock basic headers with urllib2" HTTPretty.register_uri(HTTPretty.GET, "http://github.com/", body="this is supposed to be the response", @@ -99,7 +99,7 @@ def test_httpretty_should_mock_headers_urllib2(now): @httprettified @within(two=microseconds) def test_httpretty_should_allow_adding_and_overwritting_urllib2(now): - u"HTTPretty should allow adding and overwritting headers with urllib2" + "HTTPretty should allow adding and overwritting headers with urllib2" HTTPretty.register_uri(HTTPretty.GET, "http://github.com/", body="this is supposed to be the response", @@ -127,7 +127,7 @@ def test_httpretty_should_allow_adding_and_overwritting_urllib2(now): @httprettified @within(two=microseconds) def test_httpretty_should_allow_forcing_headers_urllib2(): - u"HTTPretty should allow forcing headers with urllib2" + "HTTPretty should allow forcing headers with urllib2" HTTPretty.register_uri(HTTPretty.GET, "http://github.com/", body="this is supposed to be the response", @@ -147,7 +147,7 @@ def test_httpretty_should_allow_forcing_headers_urllib2(): @httprettified @within(two=microseconds) def test_httpretty_should_allow_adding_and_overwritting_by_kwargs_u2(now): - u"HTTPretty should allow adding and overwritting headers by " \ + "HTTPretty should allow adding and overwritting headers by " \ "keyword args with urllib2" body = "this is supposed to be the response, indeed" @@ -175,7 +175,7 @@ def test_httpretty_should_allow_adding_and_overwritting_by_kwargs_u2(now): @httprettified @within(two=microseconds) def test_httpretty_should_support_a_list_of_successive_responses_urllib2(now): - u"HTTPretty should support adding a list of successive " \ + "HTTPretty should support adding a list of successive " \ "responses with urllib2" HTTPretty.register_uri( @@ -208,7 +208,7 @@ def test_httpretty_should_support_a_list_of_successive_responses_urllib2(now): @httprettified @within(two=microseconds) def test_can_inspect_last_request(now): - u"HTTPretty.last_request is a mimetools.Message request from last match" + "HTTPretty.last_request is a mimetools.Message request from last match" HTTPretty.register_uri(HTTPretty.POST, "http://api.github.com/", body='{"repositories": ["HTTPretty", "lettuce"]}') @@ -237,7 +237,7 @@ def test_can_inspect_last_request(now): @httprettified @within(two=microseconds) def test_can_inspect_last_request_with_ssl(now): - u"HTTPretty.last_request is recorded even when mocking 'https' (SSL)" + "HTTPretty.last_request is recorded even when mocking 'https' (SSL)" HTTPretty.register_uri(HTTPretty.POST, "https://secure.github.com/", body='{"repositories": ["HTTPretty", "lettuce"]}') @@ -266,7 +266,7 @@ def test_can_inspect_last_request_with_ssl(now): @httprettified @within(two=microseconds) def test_httpretty_ignores_querystrings_from_registered_uri(): - u"HTTPretty should mock a simple GET with urllib2.read()" + "HTTPretty should mock a simple GET with urllib2.read()" HTTPretty.register_uri(HTTPretty.GET, "http://yipit.com/?id=123", body="Find the best daily deals") @@ -319,7 +319,7 @@ def test_callback_response(now): @httprettified def test_httpretty_should_allow_registering_regexes(): - u"HTTPretty should allow registering regexes with urllib2" + "HTTPretty should allow registering regexes with urllib2" HTTPretty.register_uri( HTTPretty.GET, diff --git a/tests/unit/test_httpretty.py b/tests/unit/test_httpretty.py index 89cb50c..e61031a 100644 --- a/tests/unit/test_httpretty.py +++ b/tests/unit/test_httpretty.py @@ -33,7 +33,7 @@ from httpretty.http import STATUSES def test_httpretty_should_raise_proper_exception_on_inconsistent_length(): - u"HTTPretty should raise proper exception on inconsistent Content-Length / "\ + "HTTPretty should raise proper exception on inconsistent Content-Length / "\ "registered response body" expect(HTTPretty.register_uri).when.called_with( HTTPretty.GET, @@ -50,7 +50,7 @@ def test_httpretty_should_raise_proper_exception_on_inconsistent_length(): def test_does_not_have_last_request_by_default(): - u'HTTPretty.last_request is a dummy object by default' + 'HTTPretty.last_request is a dummy object by default' HTTPretty.reset() expect(HTTPretty.last_request.headers).to.be.empty @@ -182,9 +182,9 @@ def test_Entry_class_normalizes_headers(): host='example.com', cache_control='no-cache', x_forward_for='proxy') expect(entry.adding_headers).to.equal({ - u'Host': u'example.com', - u'Cache-Control': u'no-cache', - u'X-Forward-For': u'proxy' + 'Host':'example.com', + 'Cache-Control':'no-cache', + 'X-Forward-For':'proxy' })