2323 urllib3_wrap_socket = None
2424
2525
26- from .compat import basestring , byte_type , decode_from_bytes , encode_to_bytes , text_type
27- from .utils import (
26+ from mocket .compat import decode_from_bytes , encode_to_bytes
27+ from mocket .utils import (
2828 MocketMode ,
2929 MocketSocketCore ,
3030 get_mocketize ,
@@ -317,7 +317,7 @@ def true_sendall(self, data, *args, **kwargs):
317317 # make request unique again
318318 req_signature = _hash_request (hasher , req )
319319 # port should be always a string
320- port = text_type (self ._port )
320+ port = str (self ._port )
321321
322322 # prepare responses dictionary
323323 responses = {}
@@ -427,7 +427,7 @@ class Mocket:
427427 _address = (None , None )
428428 _entries = collections .defaultdict (list )
429429 _requests = []
430- _namespace = text_type (id (_entries ))
430+ _namespace = str (id (_entries ))
431431 _truesocket_recording_dir = None
432432
433433 @classmethod
@@ -518,7 +518,7 @@ def enable(namespace=None, truesocket_recording_dir=None):
518518 socket .socketpair = socket .__dict__ ["socketpair" ] = socketpair
519519 ssl .wrap_socket = ssl .__dict__ ["wrap_socket" ] = FakeSSLContext .wrap_socket
520520 ssl .SSLContext = ssl .__dict__ ["SSLContext" ] = FakeSSLContext
521- socket .inet_pton = socket .__dict__ ["inet_pton" ] = lambda family , ip : byte_type (
521+ socket .inet_pton = socket .__dict__ ["inet_pton" ] = lambda family , ip : bytes (
522522 "\x7f \x00 \x00 \x01 " , "utf-8"
523523 )
524524 urllib3 .util .ssl_ .wrap_socket = urllib3 .util .ssl_ .__dict__ ["wrap_socket" ] = (
@@ -592,13 +592,13 @@ def assert_fail_if_entries_not_served(cls):
592592
593593
594594class MocketEntry :
595- class Response (byte_type ):
595+ class Response (bytes ):
596596 @property
597597 def data (self ):
598598 return self
599599
600600 response_index = 0
601- request_cls = byte_type
601+ request_cls = bytes
602602 response_cls = Response
603603 responses = None
604604 _served = None
@@ -607,9 +607,7 @@ def __init__(self, location, responses):
607607 self ._served = False
608608 self .location = location
609609
610- if not isinstance (responses , collections_abc .Iterable ) or isinstance (
611- responses , basestring
612- ):
610+ if not isinstance (responses , collections_abc .Iterable ):
613611 responses = [responses ]
614612
615613 if not responses :
@@ -618,7 +616,7 @@ def __init__(self, location, responses):
618616 self .responses = []
619617 for r in responses :
620618 if not isinstance (r , BaseException ) and not getattr (r , "data" , False ):
621- if isinstance (r , text_type ):
619+ if isinstance (r , str ):
622620 r = encode_to_bytes (r )
623621 r = self .response_cls (r )
624622 self .responses .append (r )
@@ -658,7 +656,7 @@ def __init__(
658656 ):
659657 self .instance = instance
660658 self .truesocket_recording_dir = truesocket_recording_dir
661- self .namespace = namespace or text_type (id (self ))
659+ self .namespace = namespace or str (id (self ))
662660 MocketMode ().STRICT = strict_mode
663661 if strict_mode :
664662 MocketMode ().STRICT_ALLOWED = strict_mode_allowed or []
0 commit comments