pytest-testkit 1.0.3a3__tar.gz → 1.1.0__tar.gz
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.
- {pytest_testkit-1.0.3a3/pytest_testkit.egg-info → pytest_testkit-1.1.0}/PKG-INFO +1 -1
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pyproject.toml +1 -1
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/__init__.py +1 -1
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/base/sftp.py +1 -1
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/base/ssh.py +6 -2
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/common/environment/device.py +10 -38
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/plugin.py +0 -1
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0/pytest_testkit.egg-info}/PKG-INFO +1 -1
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/LICENSE +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/MANIFEST.in +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/README.md +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/__init__.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/base/__init__.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/base/excel.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/base/ftp.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/base/local_exec.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/common/__init__.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/common/environment/__init__.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/common/environment/allocator.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/common/environment/manager.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/common/log/__init__.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/common/log/filters.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/common/log/infra_logger.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/common/log/manager.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/pre_action/__init__.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/pre_action/action.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/pre_action/exceptions.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/pre_action/registry.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit.egg-info/SOURCES.txt +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit.egg-info/dependency_links.txt +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit.egg-info/entry_points.txt +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit.egg-info/requires.txt +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit.egg-info/top_level.txt +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/requirements.txt +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/setup.cfg +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_collect_case_with_inifile.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_docker_proxy_creation.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_docker_proxy_exit_docker.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_docker_proxy_getitem.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_docker_proxy_integration.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_docker_proxy_is_interactive_shell.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_docker_proxy_non_shell_commands.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_docker_proxy_sendcmd.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_docker_proxy_sendcmd_interactive.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_env_nodes_filter.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_get_inifile_info.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_get_item_case_info.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_local_exec.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_local_interactive.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_log_factory.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_log_factory_integration.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_security_features.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_ssh_cwd.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_ssh_file_ops.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_ssh_ignore_err.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_ssh_only_stdout.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_ssh_remove_command_echo.py +0 -0
- {pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_ssh_success.py +0 -0
|
@@ -46,7 +46,10 @@ class SshCmdInteractiveParam:
|
|
|
46
46
|
|
|
47
47
|
class Ssh:
|
|
48
48
|
# 提示符核心格式:匹配各种 shell 提示符的 $ 或 # 符号前的部分
|
|
49
|
-
_PROMPT_CORE =
|
|
49
|
+
_PROMPT_CORE = (
|
|
50
|
+
r"(?:\[.+@.+\s+.+\]|[^@\s]+@[\w.-]+\s+.+|[^@]+@[^:]+:.+|"
|
|
51
|
+
r"bash-[0-9.]+|sh-[0-9.]+)[#$]"
|
|
52
|
+
)
|
|
50
53
|
# 完整提示符模式:可选的虚拟环境前缀 + 核心提示符
|
|
51
54
|
_PROMPT_PATTERN = re.compile(rf"^(\([^)]+\)\s*)*{_PROMPT_CORE}\s*$")
|
|
52
55
|
|
|
@@ -183,7 +186,8 @@ class Ssh:
|
|
|
183
186
|
str: 识别到的提示符, 未识别返回空串
|
|
184
187
|
"""
|
|
185
188
|
prompt_regex = re.compile(
|
|
186
|
-
r"^\s*((?:\([^)]+\)\s*)*(?:\[.+@.+\s+.+\]|
|
|
189
|
+
r"^\s*((?:\([^)]+\)\s*)*(?:\[.+@.+\s+.+\]|"
|
|
190
|
+
r"[^@\s]+@[\w.-]+\s+.+|[^@\s]+@[^:\s]+:[^\s]*|"
|
|
187
191
|
r"bash-[0-9.]+|sh-[0-9.]+)[#$]|[$#%>])\s*$",
|
|
188
192
|
re.MULTILINE,
|
|
189
193
|
)
|
{pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/common/environment/device.py
RENAMED
|
@@ -30,6 +30,8 @@ class LogColor:
|
|
|
30
30
|
# 类加载时根据终端支持情况设置颜色常量
|
|
31
31
|
CYAN = "\033[36m" if _supports_color() else ""
|
|
32
32
|
GREEN = "\033[32m" if _supports_color() else ""
|
|
33
|
+
RED = "\033[31m" if _supports_color() else ""
|
|
34
|
+
YELLOW = "\033[33m" if _supports_color() else ""
|
|
33
35
|
RESET = "\033[0m" if _supports_color() else ""
|
|
34
36
|
|
|
35
37
|
|
|
@@ -593,13 +595,6 @@ class Device:
|
|
|
593
595
|
if self._get_logged_in():
|
|
594
596
|
return True
|
|
595
597
|
|
|
596
|
-
# 登录动作日志: HTML location 列显示 login[设备短名]
|
|
597
|
-
# 改成框架日志,不在此处打印
|
|
598
|
-
# logger.info(
|
|
599
|
-
# f"Logging in to device: {self.name}",
|
|
600
|
-
# extra={"op_type": f"login[{_short_name(self.name)}]"},
|
|
601
|
-
# )
|
|
602
|
-
|
|
603
598
|
# Implement actual SSH connection logic
|
|
604
599
|
# 由于有跳板机,需要先登录跳板机,再登录目标设备
|
|
605
600
|
# 这里简化处理,直接使用目标设备信息
|
|
@@ -618,27 +613,12 @@ class Device:
|
|
|
618
613
|
)
|
|
619
614
|
login_result = self._thread_local.sshConnect.login()
|
|
620
615
|
if login_result is False:
|
|
621
|
-
# 改成框架日志,不在此处打印 这个是否不用修改
|
|
622
|
-
# logger.error(
|
|
623
|
-
# f"ssh login failed for {self.__str__()}",
|
|
624
|
-
# extra={"op_type": f"loginresult[{_short_name(self.name)}]"},
|
|
625
|
-
# )
|
|
626
616
|
return False
|
|
627
617
|
self._set_logged_in(True)
|
|
628
|
-
# 改成框架日志,不在此处打印
|
|
629
|
-
# logger.info(
|
|
630
|
-
# f"Successfully connected to {self.__str__()}",
|
|
631
|
-
# extra={"op_type": f"loginresult[{_short_name(self.name)}]"},
|
|
632
|
-
# )
|
|
633
618
|
# 登录后立即预创建交互 channel 并吸收 banner,
|
|
634
619
|
# 保证 loginecho 出现在第一条 sendcmd 之前
|
|
635
620
|
login_echo = self._thread_local.sshConnect.prepare_interactive_channel()
|
|
636
621
|
if login_echo:
|
|
637
|
-
# 改成框架日志,不在此处打印
|
|
638
|
-
# logger.info(
|
|
639
|
-
# login_echo,
|
|
640
|
-
# extra={"op_type": f"loginecho[{_short_name(self.name)}]"},
|
|
641
|
-
# )
|
|
642
622
|
self._thread_local.sshConnect._login_echo_logged = True
|
|
643
623
|
return True
|
|
644
624
|
|
|
@@ -754,11 +734,6 @@ class Device:
|
|
|
754
734
|
if getattr(ssh_connect, "login_echo", "") and not getattr(
|
|
755
735
|
ssh_connect, "_login_echo_logged", False
|
|
756
736
|
):
|
|
757
|
-
# 改成框架日志,不在此处打印
|
|
758
|
-
# logger.info(
|
|
759
|
-
# ssh_connect.login_echo,
|
|
760
|
-
# extra={"op_type": f"loginecho[{_short_name(self.name)}]"},
|
|
761
|
-
# )
|
|
762
737
|
ssh_connect._login_echo_logged = True
|
|
763
738
|
|
|
764
739
|
param = SshCmdInteractiveParam(
|
|
@@ -799,9 +774,15 @@ class Device:
|
|
|
799
774
|
recv_msg = result_echo[: -len(new_prompt)].rstrip("\n")
|
|
800
775
|
else:
|
|
801
776
|
recv_msg = result_echo
|
|
802
|
-
logger.info(
|
|
777
|
+
logger.info(
|
|
778
|
+
f"{LogColor.YELLOW}{recv_msg}{LogColor.RESET}",
|
|
779
|
+
extra={"op_type": f"recvcmd{node_tag}"},
|
|
780
|
+
)
|
|
803
781
|
else:
|
|
804
|
-
logger.info(
|
|
782
|
+
logger.info(
|
|
783
|
+
f"{LogColor.YELLOW}(empty){LogColor.RESET}",
|
|
784
|
+
extra={"op_type": f"recvcmd{node_tag}"},
|
|
785
|
+
)
|
|
805
786
|
|
|
806
787
|
# 移除 stdout 末尾的 shell 提示符
|
|
807
788
|
if new_prompt:
|
|
@@ -809,9 +790,6 @@ class Device:
|
|
|
809
790
|
if stdout_val.endswith(new_prompt):
|
|
810
791
|
result_dict["stdout"] = stdout_val[: -len(new_prompt)]
|
|
811
792
|
|
|
812
|
-
logger.info(f"test tzing1: {new_prompt}")
|
|
813
|
-
logger.info(f"test tzing2: {result_dict}")
|
|
814
|
-
|
|
815
793
|
# 按用户原始 only_stdout 决定返回值
|
|
816
794
|
if only_stdout:
|
|
817
795
|
return result_dict.get("stdout", "")
|
|
@@ -1083,12 +1061,6 @@ class Device:
|
|
|
1083
1061
|
self._thread_local.sshConnect.close()
|
|
1084
1062
|
self._set_logged_in(False)
|
|
1085
1063
|
|
|
1086
|
-
# # 移除 放到调度日志中
|
|
1087
|
-
# logger.info(
|
|
1088
|
-
# f"Disconnected from {self.__str__()}",
|
|
1089
|
-
# extra={"op_type": f"disconnect[{_short_name(self.name)}]"},
|
|
1090
|
-
# )
|
|
1091
|
-
|
|
1092
1064
|
return True
|
|
1093
1065
|
except Exception as e:
|
|
1094
1066
|
logger.error(
|
|
@@ -1064,7 +1064,6 @@ def pytest_runtest_teardown(item):
|
|
|
1064
1064
|
if item.config.env_initialized and hasattr(item, "infra_environments"):
|
|
1065
1065
|
env_manager = item.config.env_manager
|
|
1066
1066
|
env_manager.release_environments(item.nodeid)
|
|
1067
|
-
# logger.info(f"Released test environments")
|
|
1068
1067
|
|
|
1069
1068
|
result = getattr(item, "infra_test_result", "unknown")
|
|
1070
1069
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/common/environment/__init__.py
RENAMED
|
File without changes
|
{pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/common/environment/allocator.py
RENAMED
|
File without changes
|
{pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/common/environment/manager.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit/lib/common/log/infra_logger.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/pytest_testkit.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_docker_proxy_is_interactive_shell.py
RENAMED
|
File without changes
|
{pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_docker_proxy_non_shell_commands.py
RENAMED
|
File without changes
|
|
File without changes
|
{pytest_testkit-1.0.3a3 → pytest_testkit-1.1.0}/tests/test_docker_proxy_sendcmd_interactive.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|