Update test framework (#16875)

### Summary

1. add colorful print
2. update the test priority

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-07-14 12:42:58 +08:00
committed by GitHub
parent f7f89b24cf
commit 13236698a6
3 changed files with 14 additions and 6 deletions

View File

@@ -255,4 +255,12 @@ def pytest_runtest_protocol(item, nextitem):
start = time.perf_counter()
yield
duration = time.perf_counter() - start
print(f" [{duration:.3f}s]")
if duration >= 10:
color = "****" # 4 stars
elif duration >= 5:
color = "***" # 3 stars
elif duration >= 1:
color = "**" # 2 stars
else:
color = ""
print(f" {color} [{duration:.3f}s]")

View File

@@ -256,7 +256,7 @@ def _set_request_json(monkeypatch, module, payload):
monkeypatch.setattr(module, "get_request_json", lambda: _AwaitableValue(deepcopy(payload)))
@pytest.mark.p2
@pytest.mark.p3
def test_retrieval_success_with_metadata_and_kg(monkeypatch):
module = _load_dify_retrieval_module(monkeypatch)
_set_request_json(
@@ -307,7 +307,7 @@ def test_retrieval_success_with_metadata_and_kg(monkeypatch):
assert "score" in top, res
@pytest.mark.p2
@pytest.mark.p3
def test_retrieval_kb_not_found(monkeypatch):
module = _load_dify_retrieval_module(monkeypatch)
_set_request_json(monkeypatch, module, {"knowledge_id": "kb-missing", "query": "hello"})

View File

@@ -148,7 +148,7 @@ def test_openai_compatible_nonstream_shape(rest_client, create_chat):
assert usage["total_tokens"] == usage["prompt_tokens"] + usage["completion_tokens"], usage
@pytest.mark.p2
@pytest.mark.p3
def test_openai_compatible_defaults_to_nonstream_when_stream_is_missing(rest_client, create_chat):
chat_id = create_chat("restful_openai_default_nonstream_chat")
res = rest_client.post(
@@ -168,7 +168,7 @@ def test_openai_compatible_defaults_to_nonstream_when_stream_is_missing(rest_cli
assert payload["choices"][0].get("finish_reason") == "stop", payload
@pytest.mark.p2
@pytest.mark.p3
def test_openai_compatible_nonstream_with_reference_output_shape(rest_client, create_chat):
chat_id = create_chat("restful_openai_reference_chat")
res = rest_client.post(
@@ -192,7 +192,7 @@ def test_openai_compatible_nonstream_with_reference_output_shape(rest_client, cr
assert isinstance(choice_msg["reference"], list), payload
@pytest.mark.p2
@pytest.mark.p3
def test_openai_compatible_stream_shape_and_done_semantics(rest_client, create_chat):
chat_id = create_chat("restful_openai_stream_chat")
res = rest_client.post(