Spaces:
Sleeping
Sleeping
| import pytest | |
| import torch | |
| from PIL import Image | |
| import numpy as np | |
| import tempfile | |
| import os | |
| def mock_device(): | |
| """Mock device for testing""" | |
| return "cpu" | |
| def sample_medical_text(): | |
| """Sample medical text for testing""" | |
| return """ | |
| Patient: John Smith, 45-year-old male | |
| Chief Complaint: Chest pain for 2 hours | |
| History: Patient reports sudden onset of sharp chest pain while at work. | |
| Pain is 7/10 intensity, located substernal, radiating to left arm. | |
| Physical Exam: VS: BP 150/90, HR 110, RR 22, O2 Sat 96% on RA. | |
| Patient appears anxious and diaphoretic. | |
| Assessment: Acute chest pain, rule out myocardial infarction | |
| Plan: EKG, cardiac enzymes, chest X-ray, aspirin 325mg | |
| """ | |
| def sample_image(): | |
| """Create a sample image for OCR testing""" | |
| # Create a simple white image with black text | |
| img = Image.new('RGB', (400, 300), color='white') | |
| return img | |
| def temp_image_file(): | |
| """Create a temporary image file""" | |
| with tempfile.NamedTemporaryFile(suffix='.png', delete=False) as tmp: | |
| img = Image.new('RGB', (400, 300), color='white') | |
| img.save(tmp.name) | |
| yield tmp.name | |
| os.unlink(tmp.name) |