Create a variety of test images for comprehensive testing.
()
| 20 | |
| 21 | |
| 22 | def create_test_images(): |
| 23 | """Create a variety of test images for comprehensive testing.""" |
| 24 | test_images = {} |
| 25 | |
| 26 | # Simple colored squares |
| 27 | test_images["red_square"] = Image.new("RGB", (224, 224), color=(255, 0, 0)) |
| 28 | test_images["blue_square"] = Image.new("RGB", (224, 224), color=(0, 0, 255)) |
| 29 | test_images["green_square"] = Image.new("RGB", (224, 224), color=(0, 255, 0)) |
| 30 | |
| 31 | # Gradient image |
| 32 | gradient = Image.new("RGB", (224, 224)) |
| 33 | for x in range(224): |
| 34 | for y in range(224): |
| 35 | gradient.putpixel((x, y), (x, y, (x + y) // 2)) |
| 36 | test_images["gradient"] = gradient |
| 37 | |
| 38 | # Simple pattern |
| 39 | pattern = Image.new("RGB", (224, 224), color=(255, 255, 255)) |
| 40 | for x in range(0, 224, 20): |
| 41 | for y in range(0, 224, 20): |
| 42 | for i in range(10): |
| 43 | for j in range(10): |
| 44 | if x + i < 224 and y + j < 224: |
| 45 | pattern.putpixel((x + i, y + j), (0, 0, 0)) |
| 46 | test_images["checkerboard"] = pattern |
| 47 | |
| 48 | # Load real image if available |
| 49 | real_image_paths = ["static/img/me.jpg", "static/img/android-chrome-512x512.png", "static/images/logo.png"] |
| 50 | |
| 51 | for path in real_image_paths: |
| 52 | if os.path.exists(path): |
| 53 | try: |
| 54 | test_images[f"real_{os.path.basename(path)}"] = Image.open(path).convert("RGB") |
| 55 | logger.info(f"Loaded real test image: {path}") |
| 56 | break |
| 57 | except Exception as e: |
| 58 | logger.warning(f"Failed to load {path}: {e}") |
| 59 | |
| 60 | return test_images |
| 61 | |
| 62 | |
| 63 | def test_basic_functionality(): |
no test coverage detected