mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-29 17:33:08 +03:00
args test
This commit is contained in:
parent
b23625172f
commit
5838d77c0e
|
@ -32,6 +32,29 @@ class TestImageReduce(PillowTestCase):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
im.reduce((0, 10))
|
im.reduce((0, 10))
|
||||||
|
|
||||||
|
def test_args_box(self):
|
||||||
|
im = Image.new("L", (10, 10))
|
||||||
|
|
||||||
|
self.assertEqual((5, 5), im.reduce(2, (0, 0, 10, 10)).size)
|
||||||
|
self.assertEqual((1, 1), im.reduce(2, (5, 5, 6, 6)).size)
|
||||||
|
|
||||||
|
with self.assertRaises(TypeError):
|
||||||
|
im.reduce(2, "stri")
|
||||||
|
with self.assertRaises(TypeError):
|
||||||
|
im.reduce(2, 2)
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
im.reduce(2, (0, 0, 11, 10))
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
im.reduce(2, (0, 0, 10, 11))
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
im.reduce(2, (-1, 0, 10, 10))
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
im.reduce(2, (0, -1, 10, 10))
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
im.reduce(2, (0, 5, 10, 5))
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
im.reduce(2, (5, 0, 5, 10))
|
||||||
|
|
||||||
def test_unsupported_modes(self):
|
def test_unsupported_modes(self):
|
||||||
im = Image.new("P", (10, 10))
|
im = Image.new("P", (10, 10))
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
|
|
|
@ -1858,7 +1858,7 @@ _reduce(ImagingObject* self, PyObject* args)
|
||||||
return ImagingError_ValueError("box can't exceed original image size");
|
return ImagingError_ValueError("box can't exceed original image size");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (box[2] < box[0] || box[3] < box[1]) {
|
if (box[2] <= box[0] || box[3] <= box[1]) {
|
||||||
return ImagingError_ValueError("box can't be empty");
|
return ImagingError_ValueError("box can't be empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user