mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 18:56:17 +03:00
Prevent register_open from adding duplicates to ID
This commit is contained in:
parent
698951e19e
commit
3e37a919b1
|
@ -398,6 +398,17 @@ class TestImage:
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
source.alpha_composite(over, (0, 0), (0, -1))
|
source.alpha_composite(over, (0, 0), (0, -1))
|
||||||
|
|
||||||
|
def test_register_open_duplicates(self):
|
||||||
|
# Arrange
|
||||||
|
factory, accept = Image.OPEN["JPEG"]
|
||||||
|
id_length = len(Image.ID)
|
||||||
|
|
||||||
|
# Act
|
||||||
|
Image.register_open("JPEG", factory, accept)
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
assert len(Image.ID) == id_length
|
||||||
|
|
||||||
def test_registered_extensions_uninitialized(self):
|
def test_registered_extensions_uninitialized(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
Image._initialized = 0
|
Image._initialized = 0
|
||||||
|
|
|
@ -3406,7 +3406,8 @@ def register_open(id, factory, accept=None):
|
||||||
reject images having another format.
|
reject images having another format.
|
||||||
"""
|
"""
|
||||||
id = id.upper()
|
id = id.upper()
|
||||||
ID.append(id)
|
if id not in ID:
|
||||||
|
ID.append(id)
|
||||||
OPEN[id] = factory, accept
|
OPEN[id] = factory, accept
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user