WebsocketTest 1.0.11__py3-none-any.whl → 1.0.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- WebsocketTest/allure_installer.py +163 -0
- WebsocketTest/libs/allure-2.30.0.zip +0 -0
- WebsocketTest/run_tests.py +28 -1
- {websockettest-1.0.11.dist-info → websockettest-1.0.12.dist-info}/METADATA +1 -1
- {websockettest-1.0.11.dist-info → websockettest-1.0.12.dist-info}/RECORD +8 -6
- {websockettest-1.0.11.dist-info → websockettest-1.0.12.dist-info}/WHEEL +0 -0
- {websockettest-1.0.11.dist-info → websockettest-1.0.12.dist-info}/entry_points.txt +0 -0
- {websockettest-1.0.11.dist-info → websockettest-1.0.12.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,163 @@
|
|
1
|
+
import os
|
2
|
+
import sys
|
3
|
+
import zipfile
|
4
|
+
import subprocess
|
5
|
+
import winreg
|
6
|
+
from pathlib import Path
|
7
|
+
|
8
|
+
# 配置参数
|
9
|
+
ALLURE_VERSION = "2.30.0"
|
10
|
+
PACKAGE_NAME = "WebsocketTest" # 您的包名
|
11
|
+
LOCAL_ZIP_RELATIVE_PATH = os.path.join("libs", f"allure-{ALLURE_VERSION}.zip") # 包内相对路径
|
12
|
+
INSTALL_DIR = os.path.expanduser("~/.allure") # 安装到用户目录
|
13
|
+
ALLURE_BIN_DIR = os.path.join(INSTALL_DIR, f"allure-{ALLURE_VERSION}", "bin")
|
14
|
+
|
15
|
+
def is_allure_installed():
|
16
|
+
"""检查Allure是否在PATH中且可执行"""
|
17
|
+
try:
|
18
|
+
# 同时检查版本避免找到无效安装
|
19
|
+
result = subprocess.run(["allure", "--version"],
|
20
|
+
check=True,
|
21
|
+
stdout=subprocess.PIPE,
|
22
|
+
stderr=subprocess.PIPE,
|
23
|
+
text=True)
|
24
|
+
installed_version = result.stdout.strip()
|
25
|
+
if ALLURE_VERSION not in installed_version:
|
26
|
+
print(f"⚠️ 发现不匹配的Allure版本: {installed_version} (需要 {ALLURE_VERSION})")
|
27
|
+
return False
|
28
|
+
return True
|
29
|
+
except (subprocess.CalledProcessError, FileNotFoundError):
|
30
|
+
return False
|
31
|
+
|
32
|
+
def get_local_zip_path():
|
33
|
+
"""获取ZIP文件的绝对路径(兼容开发模式和正式安装)"""
|
34
|
+
# 尝试从包内获取
|
35
|
+
try:
|
36
|
+
import importlib.resources as pkg_resources
|
37
|
+
with pkg_resources.path(PACKAGE_NAME, LOCAL_ZIP_RELATIVE_PATH) as zip_path:
|
38
|
+
return str(zip_path)
|
39
|
+
except:
|
40
|
+
pass
|
41
|
+
|
42
|
+
# 回退方案:从当前工作目录查找
|
43
|
+
base_dirs = [
|
44
|
+
os.getcwd(),
|
45
|
+
os.path.dirname(os.path.abspath(__file__)),
|
46
|
+
sys.prefix
|
47
|
+
]
|
48
|
+
|
49
|
+
for base in base_dirs:
|
50
|
+
zip_path = os.path.join(base, PACKAGE_NAME, LOCAL_ZIP_RELATIVE_PATH)
|
51
|
+
if os.path.exists(zip_path):
|
52
|
+
return zip_path
|
53
|
+
|
54
|
+
raise FileNotFoundError(f"Allure ZIP文件未在任何位置找到: {LOCAL_ZIP_RELATIVE_PATH}")
|
55
|
+
|
56
|
+
def install_allure():
|
57
|
+
"""从本地ZIP安装Allure"""
|
58
|
+
try:
|
59
|
+
zip_path = get_local_zip_path()
|
60
|
+
print(f"🔍 找到Allure ZIP文件: {zip_path}")
|
61
|
+
|
62
|
+
# 创建安装目录
|
63
|
+
os.makedirs(INSTALL_DIR, exist_ok=True)
|
64
|
+
print(f"📦 解压到: {INSTALL_DIR}")
|
65
|
+
|
66
|
+
# 解压ZIP文件(使用更安全的提取方法)
|
67
|
+
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
68
|
+
for file in zip_ref.namelist():
|
69
|
+
# 防止Zip Slip攻击
|
70
|
+
safe_path = os.path.join(INSTALL_DIR, *file.split('/'))
|
71
|
+
if file.endswith('/'):
|
72
|
+
os.makedirs(safe_path, exist_ok=True)
|
73
|
+
else:
|
74
|
+
with open(safe_path, 'wb') as f:
|
75
|
+
f.write(zip_ref.read(file))
|
76
|
+
|
77
|
+
# 设置权限(特别是Linux/macOS)
|
78
|
+
if sys.platform != "win32":
|
79
|
+
os.chmod(os.path.join(ALLURE_BIN_DIR, "allure"), 0o755)
|
80
|
+
|
81
|
+
# 更新PATH
|
82
|
+
if add_to_user_path(ALLURE_BIN_DIR):
|
83
|
+
# 立即在当前进程生效
|
84
|
+
os.environ["PATH"] = f"{ALLURE_BIN_DIR}{os.pathsep}{os.environ.get('PATH', '')}"
|
85
|
+
|
86
|
+
return True
|
87
|
+
except Exception as e:
|
88
|
+
print(f"❌ 安装失败: {type(e).__name__}: {e}", file=sys.stderr)
|
89
|
+
return False
|
90
|
+
|
91
|
+
def add_to_user_path(path):
|
92
|
+
"""添加到用户级PATH环境变量"""
|
93
|
+
try:
|
94
|
+
if sys.platform == "win32":
|
95
|
+
# Windows注册表操作
|
96
|
+
with winreg.OpenKey(
|
97
|
+
winreg.HKEY_CURRENT_USER,
|
98
|
+
r"Environment",
|
99
|
+
0,
|
100
|
+
winreg.KEY_READ | winreg.KEY_WRITE,
|
101
|
+
) as key:
|
102
|
+
current_path, _ = winreg.QueryValueEx(key, "Path")
|
103
|
+
|
104
|
+
if path in current_path.split(os.pathsep):
|
105
|
+
return False
|
106
|
+
|
107
|
+
new_path = f"{current_path}{os.pathsep}{path}" if current_path else path
|
108
|
+
winreg.SetValueEx(key, "Path", 0, winreg.REG_EXPAND_SZ, new_path)
|
109
|
+
|
110
|
+
# 刷新环境变量
|
111
|
+
subprocess.run(
|
112
|
+
'powershell -command "[Environment]::SetEnvironmentVariable(\'Path\', $env:Path + \';{}\', \'User\')"'
|
113
|
+
.format(path),
|
114
|
+
shell=True,
|
115
|
+
check=True
|
116
|
+
)
|
117
|
+
else:
|
118
|
+
# Linux/macOS: 修改shell配置文件
|
119
|
+
shell_config = os.path.expanduser("~/.bashrc")
|
120
|
+
if not os.path.exists(shell_config):
|
121
|
+
shell_config = os.path.expanduser("~/.zshrc")
|
122
|
+
|
123
|
+
with open(shell_config, "a") as f:
|
124
|
+
f.write(f"\nexport PATH=\"$PATH:{path}\"\n")
|
125
|
+
|
126
|
+
print(f"✅ 已添加PATH: {path}")
|
127
|
+
return True
|
128
|
+
except Exception as e:
|
129
|
+
print(f"⚠️ 添加PATH失败: {e}\n请手动添加 {path} 到环境变量", file=sys.stderr)
|
130
|
+
return False
|
131
|
+
|
132
|
+
def ensure_allure():
|
133
|
+
"""确保Allure已安装"""
|
134
|
+
if is_allure_installed():
|
135
|
+
print(f"✅ Allure {ALLURE_VERSION} 已安装")
|
136
|
+
return True
|
137
|
+
|
138
|
+
print("🔧 检测到Allure未安装,开始自动安装...")
|
139
|
+
if install_allure():
|
140
|
+
if not is_allure_installed():
|
141
|
+
print("""
|
142
|
+
\n⚠️ 安装成功但Allure仍未识别,可能是因为:
|
143
|
+
1. 需要重启终端使PATH生效
|
144
|
+
2. 尝试手动运行: {}
|
145
|
+
""".format(os.path.join(ALLURE_BIN_DIR, "allure" + (".bat" if sys.platform == "win32" else ""))))
|
146
|
+
return False
|
147
|
+
return True
|
148
|
+
else:
|
149
|
+
print(f"""
|
150
|
+
\n❌ 自动安装失败,请手动操作:
|
151
|
+
1. 解压 {get_local_zip_path()} 到任意目录(推荐 {INSTALL_DIR})
|
152
|
+
2. 将解压后的bin目录添加到PATH:
|
153
|
+
- Windows: 添加 {ALLURE_BIN_DIR} 到系统环境变量
|
154
|
+
- Linux/macOS: 在~/.bashrc或~/.zshrc中添加:
|
155
|
+
export PATH="$PATH:{ALLURE_BIN_DIR}"
|
156
|
+
3. 运行 `allure --version` 验证
|
157
|
+
""")
|
158
|
+
return False
|
159
|
+
|
160
|
+
if __name__ == "__main__":
|
161
|
+
if ensure_allure():
|
162
|
+
sys.exit(0)
|
163
|
+
sys.exit(1)
|
Binary file
|
WebsocketTest/run_tests.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import subprocess
|
2
2
|
import argparse
|
3
3
|
import shutil
|
4
|
-
import time
|
4
|
+
import time,platform
|
5
5
|
import webbrowser
|
6
6
|
from urllib.request import urlopen
|
7
7
|
from urllib.error import URLError
|
@@ -93,6 +93,33 @@ class TestRunner:
|
|
93
93
|
logger.error(f"Tests failed with exit code {e.returncode}")
|
94
94
|
except subprocess.TimeoutExpired:
|
95
95
|
logger.error("Test execution timed out after 1 hour")
|
96
|
+
def is_allure_installed():
|
97
|
+
"""检查 Allure 是否已安装"""
|
98
|
+
try:
|
99
|
+
# 尝试运行 allure --version
|
100
|
+
result = subprocess.run(
|
101
|
+
["allure", "--version"],
|
102
|
+
stdout=subprocess.PIPE,
|
103
|
+
stderr=subprocess.PIPE,
|
104
|
+
text=True,
|
105
|
+
)
|
106
|
+
return result.returncode == 0
|
107
|
+
except FileNotFoundError:
|
108
|
+
return False
|
109
|
+
|
110
|
+
def install_allure():
|
111
|
+
"""根据操作系统自动安装 Allure"""
|
112
|
+
system = platform.system().lower()
|
113
|
+
|
114
|
+
if system == "windows":
|
115
|
+
# Windows 使用 scoop 安装
|
116
|
+
if not shutil.which("scoop"):
|
117
|
+
print("⚠️ 请先安装 Scoop (https://scoop.sh/)")
|
118
|
+
exit(1)
|
119
|
+
subprocess.run(["scoop", "install", "allure"], check=True)
|
120
|
+
else:
|
121
|
+
print(f"❌ 不支持的操作系统: {system}")
|
122
|
+
exit(1)
|
96
123
|
|
97
124
|
def generate_allure_report(self) -> bool:
|
98
125
|
"""生成Allure报告"""
|
@@ -1,7 +1,8 @@
|
|
1
1
|
WebsocketTest/__init__.py,sha256=u71SAVmbgsyp0K21kilo7pIDgeyxsaHAi93clC0OIPQ,556
|
2
|
+
WebsocketTest/allure_installer.py,sha256=OicATAGPC2EBMCxjoKlgFFJA8lfT-qDjakLWwDA8IAU,6194
|
2
3
|
WebsocketTest/cli.py,sha256=HcnjgRLM404fVszrSRAf7G1y9XLJ_ZetVtRIwavS4xE,987
|
3
4
|
WebsocketTest/conftest.py,sha256=xD7IK7airvGH9cDbES-G9PaKUdPazVuv3utB_UfRV-8,1875
|
4
|
-
WebsocketTest/run_tests.py,sha256=
|
5
|
+
WebsocketTest/run_tests.py,sha256=xIe1QpWUT2LKEQ9yFoDQVZlV4epYhe2YqTktR-jAKis,7099
|
5
6
|
WebsocketTest/caseScript/Aqua.py,sha256=dTjVd4FPka5lMUvxa1DsGTJ6gx7NRo5NGNunrue3d0M,7439
|
6
7
|
WebsocketTest/caseScript/Gateway.py,sha256=4_BlJPbn6X_eFHYz2orn3fXPQMPz5jRdUlj6tXkeX2Q,11748
|
7
8
|
WebsocketTest/caseScript/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -14,6 +15,7 @@ WebsocketTest/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
|
|
14
15
|
WebsocketTest/common/assertUtils.py,sha256=poyL6J_WXb2BJvaABCILfiWHN7gHSTRcMWvpjk224yU,4713
|
15
16
|
WebsocketTest/common/logger.py,sha256=JY7dJLVObKoA6E-5FJ0EMX_EyN8Otg4_4FYywKVSkcg,367
|
16
17
|
WebsocketTest/common/utils.py,sha256=DfRwSqbci1w-omUjO4TlkqTqlc-_69Gs9JQtwL3-YSo,8704
|
18
|
+
WebsocketTest/libs/allure-2.30.0.zip,sha256=SEc2gYElQbTQrIcpJ5gLIWptfPW8kPITU8gs4wezZho,26551281
|
17
19
|
WebsocketTest/templates/basic/conftest.py,sha256=y2_2961mhCYSRMp5X9xLq3nOmRzaTSgD3GDdrlTqxn4,1885
|
18
20
|
WebsocketTest/templates/basic/pytest.ini,sha256=An32MB2Yy2L4EVP9WoczW8x0ISAXsgG0tlSLta-cDcs,589
|
19
21
|
WebsocketTest/templates/basic/config/svw/live.yml,sha256=dqTMDubVYO0lt2kPoHgbZW0ZVMaLO7-OjfBmHedqJuU,31
|
@@ -80,8 +82,8 @@ WebsocketTest/templates/basic/testcase/__pycache__/test_gateway.cpython-310-pyte
|
|
80
82
|
WebsocketTest/templates/basic/testcase/__pycache__/test_gateway1.cpython-310-pytest-8.2.2.pyc,sha256=9_jiZtyNwQfXe-Jz1acHxrwz5snYfBngqgTFtIWhRNA,5684
|
81
83
|
WebsocketTest/templates/basic/testcase/__pycache__/test_gatewaybak.cpython-310-pytest-8.2.2.pyc,sha256=L50gNeQvSuFq2e-arnmKqYJR75ZrThiVaiIow5UUTjo,5587
|
82
84
|
WebsocketTest/templates/basic/testcase/__pycache__/test_limin.cpython-310-pytest-8.2.2.pyc,sha256=hx7j0GNxlgTscC36dUBHeo401Mo3bRt1cq6t7e7dDSA,3434
|
83
|
-
websockettest-1.0.
|
84
|
-
websockettest-1.0.
|
85
|
-
websockettest-1.0.
|
86
|
-
websockettest-1.0.
|
87
|
-
websockettest-1.0.
|
85
|
+
websockettest-1.0.12.dist-info/METADATA,sha256=q9VGwnji09k25ZtJ9F85Qo9qImQvv_X3-tpdqM2zZyM,334
|
86
|
+
websockettest-1.0.12.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
87
|
+
websockettest-1.0.12.dist-info/entry_points.txt,sha256=9-0RmZ0nVgfDKaDFyk5xv8arp_us-7w5Negvis1CvYc,46
|
88
|
+
websockettest-1.0.12.dist-info/top_level.txt,sha256=2iF1gZSbXLjVFOe5ZKQiCLC1FzAwhcQUM88yGi-vrCU,14
|
89
|
+
websockettest-1.0.12.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|