Non travis env and py3 no-unicode fix

This commit is contained in:
2015-12-24 12:49:59 +05:30
parent a127bc4af7
commit 43f875e18c
+8 -5
View File
@@ -14,7 +14,7 @@ if env_redis_port:
else: else:
REDIS_PORT = 5946 REDIS_PORT = 5946
if os.environ["TRAVIS"] == "true": if os.environ.get("TRAVIS") == "true":
command_redis_server_gen = "redis-server --port {port}" command_redis_server_gen = "redis-server --port {port}"
else: else:
command_redis_server_gen = "redis-server --port {port} --maxheap 20MB" command_redis_server_gen = "redis-server --port {port} --maxheap 20MB"
@@ -42,17 +42,20 @@ def s(input_):
If list, do it for all of them. If list, do it for all of them.
If others, return as is. ''' If others, return as is. '''
import sys
PY3 = sys.version_info > (3,)
if hasattr(input_, "__iter__"): if hasattr(input_, "__iter__"):
return [s(ele) for ele in input_] return [s(ele) for ele in input_]
try: try:
assert(type(input_) in [str, unicode, bytes]) if PY3:
assert(type(input_) in [str, unicode, bytes])
else:
assert(type(input_) in [str, bytes])
except AssertionError: except AssertionError:
return input_ return input_
import sys
PY3 = sys.version_info > (3,)
if PY3: if PY3:
if type(input_) == bytes: if type(input_) == bytes:
str_ = bytes.decode(input_) str_ = bytes.decode(input_)