-
Notifications
You must be signed in to change notification settings - Fork 1
fix(bindings): update tests for JXL encoding support #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| group=io.clroot.slimg | ||
| version=0.4.0 | ||
| version=0.5.0 | ||
| kotlin.code.style=official |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,9 +47,10 @@ def test_format_enum_accepted(self, sample_image): | |
| result = slimg.convert(sample_image, format=slimg.Format.PNG, quality=80) | ||
| assert result.format == slimg.Format.PNG | ||
|
|
||
| def test_jxl_encode_raises(self, sample_image): | ||
| with pytest.raises(slimg.SlimgError): | ||
| slimg.convert(sample_image, format="jxl", quality=80) | ||
| def test_to_jxl(self, sample_image): | ||
| result = slimg.convert(sample_image, format="jxl", quality=80) | ||
| assert result.format == slimg.Format.JXL | ||
| assert len(result.data) > 0 | ||
|
Comment on lines
+50
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 다른 포맷의 테스트와 일관성을 유지하고 테스트를 더 견고하게 만들기 위해 JXL 매직 바이트를 확인하는 단언문(assertion)을 추가하는 것이 좋습니다. JXL은 두 가지 시그니처(bare codestream 또는 container)를 가질 수 있습니다. def test_to_jxl(self, sample_image):
result = slimg.convert(sample_image, format="jxl", quality=80)
assert result.format == slimg.Format.JXL
assert len(result.data) > 0
# JXL can have a bare codestream (FF 0A) or be in a container (JXL ).
is_bare = result.data[:2] == b'\xff\x0a'
is_container = len(result.data) >= 8 and result.data[:4] == b'\x00\x00\x00\x0c' and result.data[4:8] == b'JXL '
assert is_bare or is_container, "JXL magic bytes not found" |
||
|
|
||
| def test_full_pipeline_crop_extend(self, sample_image_100): | ||
| result = slimg.convert( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,8 +32,8 @@ def test_png_can_encode(self): | |
| def test_webp_can_encode(self): | ||
| assert slimg.Format.WEBP.can_encode is True | ||
|
|
||
| def test_jxl_cannot_encode(self): | ||
| assert slimg.Format.JXL.can_encode is False | ||
| def test_jxl_can_encode(self): | ||
| assert slimg.Format.JXL.can_encode is True | ||
|
Comment on lines
+35
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 테스트 클래스는 현재 모든 포맷을 다루고 있지 않으며(AVIF, QOI 누락), 각 포맷에 대한 테스트가 중복됩니다. import pytest
import slimg
@pytest.mark.parametrize("format_enum", list(slimg.Format))
def test_all_formats_can_encode(format_enum):
assert format_enum.can_encode is True이렇게 하면 |
||
|
|
||
|
|
||
| class TestFormatFromPath: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 테스트는 모든
Format열거형 멤버를 순회하도록 리팩터링하여 향후 새로운 포맷이 추가될 때 테스트가 자동으로 확장되도록 할 수 있습니다. 이렇게 하면 유지보수성이 향상됩니다.