diff --git a/Pipfile b/Pipfile index deeedbff..f98fcf46 100644 --- a/Pipfile +++ b/Pipfile @@ -24,6 +24,9 @@ twine = "*" anaconda-client = "*" pipfile = "*" wheel = "*" +xxhash = "*" +aiohttp = "*" +async-timeout = "*" [requires] python_version = "3.8" diff --git a/mocket/compat.py b/mocket/compat.py index 5b5f017e..8165d7c2 100644 --- a/mocket/compat.py +++ b/mocket/compat.py @@ -2,28 +2,20 @@ import os import shlex -encoding = os.getenv("MOCKET_ENCODING", "utf-8") +ENCODING = os.getenv("MOCKET_ENCODING", "utf-8") text_type = str byte_type = bytes basestring = (str,) -FileNotFoundError = FileNotFoundError -BlockingIOError = BlockingIOError -try: - from json.decoder import JSONDecodeError -except ImportError: - JSONDecodeError = ValueError - - -def encode_to_bytes(s, encoding=encoding): +def encode_to_bytes(s, encoding=ENCODING): if isinstance(s, text_type): s = s.encode(encoding) return byte_type(s) -def decode_from_bytes(s, encoding=encoding): +def decode_from_bytes(s, encoding=ENCODING): if isinstance(s, byte_type): s = codecs.decode(s, encoding, "ignore") return text_type(s) diff --git a/mocket/mocket.py b/mocket/mocket.py index c4e3cafe..d8b1ab93 100644 --- a/mocket/mocket.py +++ b/mocket/mocket.py @@ -9,6 +9,7 @@ import socket import ssl from datetime import datetime, timedelta +from json.decoder import JSONDecodeError import decorator import urllib3 @@ -16,9 +17,6 @@ from urllib3.util.ssl_ import wrap_socket as urllib3_wrap_socket from .compat import ( - BlockingIOError, - FileNotFoundError, - JSONDecodeError, basestring, byte_type, decode_from_bytes, diff --git a/run_tests.py b/run_tests.py index 8cfcfd64..61420451 100644 --- a/run_tests.py +++ b/run_tests.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -import os import sys @@ -11,24 +10,10 @@ def main(args=None): major, minor = sys.version_info[:2] - python35 = False - - extras = ["xxhash"] - - # aiohttp available on Python >=3.5 - if major == 3 and minor >= 5: - python35 = True - - extras += ["aiohttp", "async_timeout"] - - os.system("pipenv run pip install {}".format(" ".join(extras))) - if not any(a for a in args[1:] if not a.startswith("-")): args.append("tests/main") args.append("mocket") - - if python35: - args.append("tests/tests35") + args.append("tests/tests35") if major == 3 and minor >= 8: args.append("tests/tests38")