优化部分代码
This commit is contained in:
parent
099f747f1b
commit
b5e78d3b5e
|
@ -101,7 +101,7 @@ if not db_config:
|
|||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def collection():
|
||||
def core():
|
||||
class Core:
|
||||
def __init__(self):
|
||||
self.requests = RestClient()
|
||||
|
@ -113,8 +113,3 @@ def collection():
|
|||
yield Core()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def core(collection):
|
||||
yield collection
|
||||
|
||||
|
||||
|
|
|
@ -52,16 +52,16 @@ class DataHandler:
|
|||
|
||||
if '{{' in value and '}}' in value and 'int.' not in value and 'str.' not in value:
|
||||
func = value[value.find('{') + 2:value.find('}')]
|
||||
return value.replace('{{%s}}' % f'{func}', str(Mock(func)()))
|
||||
return value.replace('{{%s}}' % func, str(Mock(func)()))
|
||||
elif '$cache.' in value:
|
||||
cache_name = value[value.find('.') + 1:]
|
||||
return self.cache_data.get(cache_name, None)
|
||||
elif 'int.' in value:
|
||||
func = value[value.find('{') + 2:value.find('}')]
|
||||
return int(value.replace('{{%s}}' % f'{func}', str(Mock(func[func.find('.') + 1:])())))
|
||||
return int(value.replace('{{%s}}' % func, str(Mock(func[func.find('.') + 1:])())))
|
||||
elif 'str.' in value:
|
||||
func = value[value.find('{') + 2:value.find('}')]
|
||||
return str(value.replace('{{%s}}' % f'{func}', str(Mock(func[func.find('.') + 1:])())))
|
||||
return str(value.replace('{{%s}}' % func, str(Mock(func[func.find('.') + 1:])())))
|
||||
else:
|
||||
return value
|
||||
|
||||
|
|
|
@ -44,12 +44,6 @@ class RestClient:
|
|||
self.cookies, self.token = Authentication.cookie_token()
|
||||
self.client = httpx.Client(cookies=self.cookies, timeout=30, verify=False)
|
||||
|
||||
def __del__(self):
|
||||
"""
|
||||
显式关闭会话
|
||||
"""
|
||||
self.client.close()
|
||||
|
||||
def res_log(func):
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
|
|
Loading…
Reference in New Issue