fix: logging KeyError with reserved 'filename' key, pytest return-not-none warnings
- api_server.py: rename 'filename' to 'file_name' in upload_file log extra dict to avoid collision with Python logging's reserved LogRecord attribute - test_e2e_ocr.py: replace return statements with assert in test functions to fix PytestReturnNotNoneWarning
This commit is contained in:
+1
-1
@@ -361,7 +361,7 @@ async def upload_file(file: UploadFile = File(...), session_id: str = ""):
|
|||||||
}
|
}
|
||||||
|
|
||||||
_api_log.info("文件上传", extra={
|
_api_log.info("文件上传", extra={
|
||||||
"file_id": file_id, "filename": safe_name, "size": len(content),
|
"file_id": file_id, "file_name": safe_name, "size": len(content),
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ def test_ocr_extraction_pipeline():
|
|||||||
print(f" 值: {fields[0].get('field_value', 'N/A')}")
|
print(f" 值: {fields[0].get('field_value', 'N/A')}")
|
||||||
print(f" 坐标: {fields[0].get('bbox', 'N/A')}")
|
print(f" 坐标: {fields[0].get('bbox', 'N/A')}")
|
||||||
|
|
||||||
return all_ok
|
# OCR field extraction is informational; verify we got a valid response
|
||||||
|
assert extraction.get("ocr_available") is not None
|
||||||
|
|
||||||
|
|
||||||
def test_validation_service():
|
def test_validation_service():
|
||||||
@@ -94,7 +95,7 @@ def test_validation_service():
|
|||||||
result = validate_jrxml("<jasperReport/>")
|
result = validate_jrxml("<jasperReport/>")
|
||||||
print(f" 状态: {'OK' if result else 'FAIL'}")
|
print(f" 状态: {'OK' if result else 'FAIL'}")
|
||||||
print(f" 响应: {result}")
|
print(f" 响应: {result}")
|
||||||
return True
|
assert result is not None
|
||||||
|
|
||||||
|
|
||||||
def test_ocr_fallback():
|
def test_ocr_fallback():
|
||||||
|
|||||||
Reference in New Issue
Block a user