forked from python-pillow/Pillow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request python-pillow#7999 from radarhere/accept
Added MPEG accept function
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from __future__ import annotations | ||
|
||
from io import BytesIO | ||
|
||
import pytest | ||
|
||
from PIL import Image, MpegImagePlugin | ||
|
||
|
||
def test_identify() -> None: | ||
# Arrange | ||
b = BytesIO(b"\x00\x00\x01\xb3\x01\x00\x01") | ||
|
||
# Act | ||
with Image.open(b) as im: | ||
# Assert | ||
assert im.format == "MPEG" | ||
|
||
assert im.mode == "RGB" | ||
assert im.size == (16, 1) | ||
|
||
|
||
def test_invalid_file() -> None: | ||
# Arrange | ||
invalid_file = "Tests/images/flower.jpg" | ||
|
||
# Act / Assert | ||
with pytest.raises(SyntaxError): | ||
MpegImagePlugin.MpegImageFile(invalid_file) | ||
|
||
|
||
def test_load() -> None: | ||
# Arrange | ||
b = BytesIO(b"\x00\x00\x01\xb3\x01\x00\x01") | ||
|
||
with Image.open(b) as im: | ||
# Act / Assert: cannot load | ||
with pytest.raises(OSError): | ||
im.load() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters