mirror of
https://github.com/bendtherules/pytest_gui_status.git
synced 2026-08-18 13:42:26 +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
|
import htmlPy
|
||||||
from .utils import render_template
|
from .utils_gui import render_template
|
||||||
import os
|
import os
|
||||||
import redis
|
import redis
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import humanfriendly
|
import humanfriendly
|
||||||
import os.path
|
import os.path
|
||||||
|
from ..utils import s
|
||||||
|
|
||||||
|
|
||||||
env_redis_port = os.environ.get("PYTEST_STATUS_PORT")
|
env_redis_port = os.environ.get("PYTEST_STATUS_PORT")
|
||||||
@@ -49,7 +50,7 @@ class Controller(htmlPy.Object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# make sure that this is correct redis db
|
# 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:
|
except AssertionError:
|
||||||
self.app_gui.stop()
|
self.app_gui.stop()
|
||||||
raise redis.exceptions.ConnectionError("Redis is running on this port, but it is not related to pytest status\n"
|
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 os
|
||||||
import psutil
|
import psutil
|
||||||
import datetime
|
import datetime
|
||||||
|
from ..utils import s
|
||||||
|
|
||||||
|
|
||||||
env_redis_port = os.environ.get("PYTEST_STATUS_PORT")
|
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
|
# 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):
|
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_
|
||||||
@@ -4,7 +4,7 @@ from mock import patch, MagicMock
|
|||||||
import redis
|
import redis
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from ..utils_test import create_temp_case, reload_2_3
|
from ..utils_test import reload_2_3
|
||||||
|
|
||||||
REDIS_TEST_PORT = status_plugin.REDIS_PORT + 1
|
REDIS_TEST_PORT = status_plugin.REDIS_PORT + 1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user