Skip to content

Commit

Permalink
Merge e8add51 into a49f071
Browse files Browse the repository at this point in the history
  • Loading branch information
mindflayer committed Jan 3, 2021
2 parents a49f071 + e8add51 commit 335d62b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 30 deletions.
3 changes: 3 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ twine = "*"
anaconda-client = "*"
pipfile = "*"
wheel = "*"
xxhash = "*"
aiohttp = "*"
async-timeout = "*"

[requires]
python_version = "3.8"
14 changes: 3 additions & 11 deletions mocket/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions mocket/mocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@
import socket
import ssl
from datetime import datetime, timedelta
from json.decoder import JSONDecodeError

import decorator
import urllib3
from urllib3.util.ssl_ import ssl_wrap_socket as urllib3_ssl_wrap_socket
from urllib3.util.ssl_ import wrap_socket as urllib3_wrap_socket

from .compat import (
BlockingIOError,
FileNotFoundError,
JSONDecodeError,
basestring,
byte_type,
decode_from_bytes,
Expand Down
17 changes: 1 addition & 16 deletions run_tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
import os
import sys


Expand All @@ -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")
Expand Down

0 comments on commit 335d62b

Please sign in to comment.