mirror of
https://github.com/bendtherules/pytest_gui_status.git
synced 2026-08-18 21:52:18 +00:00
Use s in test_gui + put it in utils + rename utils in gui
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import htmlPy
|
||||
from .utils import render_template
|
||||
from .utils_gui import render_template
|
||||
import os
|
||||
import redis
|
||||
import dateutil.parser
|
||||
from datetime import datetime
|
||||
import humanfriendly
|
||||
import os.path
|
||||
from ..utils import s
|
||||
|
||||
|
||||
env_redis_port = os.environ.get("PYTEST_STATUS_PORT")
|
||||
@@ -49,7 +50,7 @@ class Controller(htmlPy.Object):
|
||||
|
||||
try:
|
||||
# make sure that this is correct redis db
|
||||
assert redis_db.get("PYTEST_STATUS_DB") == "1"
|
||||
assert s(redis_db.get("PYTEST_STATUS_DB")) == "1"
|
||||
except AssertionError:
|
||||
self.app_gui.stop()
|
||||
raise redis.exceptions.ConnectionError("Redis is running on this port, but it is not related to pytest status\n"
|
||||
|
||||
@@ -6,6 +6,7 @@ import redis
|
||||
import os
|
||||
import psutil
|
||||
import datetime
|
||||
from ..utils import s
|
||||
|
||||
|
||||
env_redis_port = os.environ.get("PYTEST_STATUS_PORT")
|
||||
@@ -39,34 +40,6 @@ command_status_gui_gen = "pytest_gui_status \"{norm_dir_name}\""
|
||||
# make bulk changes with pipeline
|
||||
|
||||
|
||||
def s(input_):
|
||||
''' Convert str or uncode or bytes to str.
|
||||
If list, do it for all of them.
|
||||
If others, return as is. '''
|
||||
|
||||
import sys
|
||||
PY3 = sys.version_info > (3,)
|
||||
|
||||
if isinstance(input_, list):
|
||||
return [s(ele) for ele in input_]
|
||||
|
||||
try:
|
||||
if PY3:
|
||||
assert(type(input_) in [str, bytes])
|
||||
else:
|
||||
assert(type(input_) in [str, unicode, bytes])
|
||||
except AssertionError:
|
||||
return input_
|
||||
|
||||
if PY3:
|
||||
if type(input_) == bytes:
|
||||
str_ = bytes.decode(input_)
|
||||
return str_
|
||||
|
||||
# either str or unicode
|
||||
str_ = str(input_)
|
||||
return str_
|
||||
|
||||
|
||||
class Helpers(object):
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
def s(input_):
|
||||
''' Convert str or uncode or bytes to str.
|
||||
If list, do it for all of them.
|
||||
If others, return as is. '''
|
||||
|
||||
import sys
|
||||
PY3 = sys.version_info > (3,)
|
||||
|
||||
if isinstance(input_, list):
|
||||
return [s(ele) for ele in input_]
|
||||
|
||||
try:
|
||||
if PY3:
|
||||
assert(type(input_) in [str, bytes])
|
||||
else:
|
||||
assert(type(input_) in [str, unicode, bytes])
|
||||
except AssertionError:
|
||||
return input_
|
||||
|
||||
if PY3:
|
||||
if type(input_) == bytes:
|
||||
str_ = bytes.decode(input_)
|
||||
return str_
|
||||
|
||||
# either str or unicode
|
||||
str_ = str(input_)
|
||||
return str_
|
||||
Reference in New Issue
Block a user