Release NaraMotion v0.26.0: Structure of Arrays (SoA), Path Arena Allocator, Uniform Grid Indexing, Dual-Buffer Rendering & Centroid Spring Pop-in
b516e00 verified Download tests/test_image.py from ArifiIslam/NaraMotion: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/ArifiIslam/NaraMotion/resolve/main/tests/test_image.py
- Command line
-
hf download hf://ArifiIslam/NaraMotion/tests/test_image.py
-
curl -L -o test_image.py https://huggingface.co/ArifiIslam/NaraMotion/resolve/main/tests/test_image.py
1.35 kB
| import os | |
| import pytest | |
| from naramotion import Image, Format, Context, Rect | |
| def test_image_creation(): | |
| img = Image(400, 300, Format.PRGB32) | |
| assert img.width == 400 | |
| assert img.height == 300 | |
| assert img.size == (400, 300) | |
| assert img.format == Format.PRGB32 | |
| assert not img.is_empty() | |
| def test_image_file_io(tmp_path): | |
| filepath = str(tmp_path / "test_io.png") | |
| img = Image(200, 200, Format.PRGB32) | |
| with Context(img) as ctx: | |
| ctx.fill_all("white") | |
| ctx.fill_circle(100, 100, 50, "red") | |
| img.write_to_file(filepath) | |
| assert os.path.exists(filepath) | |
| assert os.path.getsize(filepath) > 0 | |
| loaded = Image.from_file(filepath) | |
| assert loaded.width == 200 | |
| assert loaded.height == 200 | |
| assert loaded.format == Format.PRGB32 | |
| def test_image_memory_bytes(): | |
| img = Image(100, 100, Format.PRGB32) | |
| with Context(img) as ctx: | |
| ctx.fill_all(0xFF00FF00) # Green | |
| data = img.to_data() | |
| assert isinstance(data, bytes) | |
| assert len(data) > 0 | |
| loaded = Image.from_data(data) | |
| assert loaded.width == 100 | |
| assert loaded.height == 100 | |
| def test_image_convert(): | |
| img = Image(100, 100, Format.PRGB32) | |
| assert img.format == Format.PRGB32 | |
| img.convert(Format.XRGB32) | |
| assert img.format == Format.XRGB32 | |