Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pytest/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "testsolar-pytestx"
version = "0.1.75"
version = "0.1.76"
description = "Pytest tool for TestSolar"
authors = [
{name = "asiazhang2002", email = "asiazhang2002@gmail.com"},
Expand Down
26 changes: 17 additions & 9 deletions pytest/src/testsolar_pytestx/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
import pytest
import contextlib
from typing import List, Tuple, TextIO, TypeVar
from typing import List, Tuple, TextIO, TypeVar, Union

T = TypeVar("T")

Expand All @@ -27,14 +27,22 @@ class TeeStream:
def __init__(self, *streams: TextIO) -> None:
self.streams = streams

def write(self, data: str) -> None:
for stream in self.streams:
# 如果是标准输出流/标准错误流则直接写入
if not isinstance(stream, io.StringIO):
stream.write(data)
# 若超过最大字符数则不写入,避免内存占用过高
elif not exceeds_max_size(stream=stream):
stream.write(data)
def write(self, data: Union[str, bytes]) -> None:
try:
# 确保 data 是字符串类型
if isinstance(data, bytes):
data = data.decode("utf-8", errors="replace")

for stream in self.streams:
# 如果是标准输出流/标准错误流则直接写入
if not isinstance(stream, io.StringIO):
stream.write(data)
# 若超过最大字符数则不写入,避免内存占用过高
elif not exceeds_max_size(stream=stream):
stream.write(data)
except Exception:
# 捕获所有异常,避免写入失败导致程序崩溃
pass

def flush(self) -> None:
for stream in self.streams:
Expand Down
2 changes: 1 addition & 1 deletion pytest/testtool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ schemaVersion: 1.0
name: pytest
nameZh: pytest自动化测试
lang: python
version: '0.1.75'
version: '0.1.76'
langType: INTERPRETED
description: |-
pytest是一个成熟的全功能Python测试工具,可以帮助您编写更好的程序。此测试工具允许您在TestSolar上运行pytest。
Expand Down
2 changes: 1 addition & 1 deletion pytest/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.