Skip to content

Commit

Permalink
更新测试启动项配置 (#199)
Browse files Browse the repository at this point in the history
* 修复allure拷贝文件逻辑

* 更新测试启动项配置
  • Loading branch information
wu-clan authored Aug 29, 2024
1 parent 67da836 commit 40e3b89
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
18 changes: 13 additions & 5 deletions httpfpt/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import pytest

from httpfpt.utils.cli.version import get_version

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from httpfpt.common.log import log
Expand All @@ -29,7 +31,6 @@

def startup(
*args,
testcase_generate: bool,
log_level: Literal['-q', '-s', '-v', '-vv'],
case_path: str | None,
html_report: bool,
Expand All @@ -44,8 +45,6 @@ def startup(
**kwargs,
) -> None:
"""运行启动程序"""
if testcase_generate:
auto_generate_testcases()

run_args = [log_level]

Expand Down Expand Up @@ -167,6 +166,7 @@ def run(
*args,
# auto testcases
testcase_generate: bool = False,
testcase_re_generation: bool = True,
# init
clean_cache: bool = False,
pydantic_verify: bool = True,
Expand All @@ -193,6 +193,7 @@ def run(
:param args: pytest 运行参数
:param testcase_generate: 自动生成测试用例(跳过同名文件),建议通过 CLI 手动执行,默认关闭
:param testcase_re_generation: 覆盖生成同名文件测试用例,建议通过 CLI 手动指定,默认开启
:param clean_cache: 清理 redis 缓存数据,对于脏数据,这很有用,默认关闭
:param pydantic_verify: 用例数据完整架构 pydantic 快速检测, 默认开启
:param args: pytest 运行参数
Expand All @@ -211,7 +212,7 @@ def run(
:return:
"""
try:
logo = """\n
logo = f"""\n
/$$ /$$ /$$$$$$$$ /$$$$$$$$ /$$$$$$$ /$$$$$$$$ /$$$$$$$ /$$$$$$$$
| $$ | $$|__ $$__/|__ $$__/| $$__ $$| $$_____/| $$__ $$|__ $$__/
| $$ | $$ | $$ | $$ | $$ | $$| $$ | $$ | $$ | $$
Expand All @@ -221,12 +222,19 @@ def run(
| $$ | $$ | $$ | $$ | $$ | $$ | $$ | $$
|__/ |__/ |__/ |__/ |__/ |__/ |__/ |__/
"""
Starting...
Version: {get_version(cli=False)}
"""
log.info(logo)
redis_client.init()
case_data.clean_cache_data(clean_cache)
case_data.case_data_init(pydantic_verify)
case_data.case_id_unique_verify()
if testcase_generate:
if not testcase_re_generation:
auto_generate_testcases()
else:
auto_generate_testcases(rewrite=True)
startup(
*args,
testcase_generate=testcase_generate,
Expand Down
6 changes: 4 additions & 2 deletions httpfpt/utils/cli/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
from httpfpt.utils.rich_console import console


def get_version() -> None:
def get_version(cli: bool = True) -> None:
"""获取版本号"""
ver = read_text('httpfpt', '__init__.py')
mob = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", ver, re.MULTILINE)
if mob:
console.print(f'\n🔥 HttpFpt [cyan]{mob.group(1)}[/]')
if cli:
console.print('')
console.print(f'HTTPFPT: [cyan]{mob.group(1)}[/]')
else:
raise cappa.Exit('\n❌ 未查询到版本号', code=1)

0 comments on commit 40e3b89

Please sign in to comment.