From 376c4f829f639ede42448f1bb92dd9aac942dfa3 Mon Sep 17 00:00:00 2001 From: moghadas76 Date: Fri, 26 May 2023 07:52:21 +0000 Subject: [PATCH 1/3] Enrich tests for putpalette function --- Tests/images/FudanPed00003_mask.png | Bin 0 -> 1807 bytes Tests/test_file_png.py | 12 ++++++++++++ 2 files changed, 12 insertions(+) create mode 100644 Tests/images/FudanPed00003_mask.png diff --git a/Tests/images/FudanPed00003_mask.png b/Tests/images/FudanPed00003_mask.png new file mode 100644 index 0000000000000000000000000000000000000000..b58d856e99340f8b66bb951c7eb0e86707a22127 GIT binary patch literal 1807 zcmbVNdsI_(93PS*C=gln03k~xMc@F@2ols(7&Z_@@zKU2^2zD)unib@iS z#bw-3kMtHuf?nJi)AOs@oM!msrZYJrxqT$I>iu!sJJq;Ix%beftFAVdT>t;d4<(1? zh+5^})3#^yYu34)2h)>iuVyqoTDRs1e9pHpD69@@C;FyjJ)v{mzl`r|+Ybx5)+)i# zG!jUa@UW<%@P;?kLBfe4)`}UbAd>z8!U;jb*y_UNh%w>meJ*qz_|;#8x(Soicl0CP zMsF@+sMMTj*QCfPoT&to7%MdlMT5LZ^J1CW=14k=F6=bDR|NnlZP{p|<|)3@c?Big z>*O58aIT{t^%v6^mEYRFs3(vxL?ud)|ToDqavZ`8Z_>M&iCvBL{5`k>S#m}hgGM#PUl_RL0oD?=O&@_D<=}R z^%*Z~GxfqU8qp{^7z!ju>zwbIrP!Dp$T0qIcgJq~wy(5`k9(r`UeVIGw$PWdWldov zOY2VkEwE+Je+)`MrScyq3OA@li&EbE=&RW19Q9Fn%yP)PuQZ(mSrY92OEZ7Pa7;9o zmgumF4(xDDo_^i7TVt2+j2ecs0SAtp)pR}q`rj?AxXhxY#>gsWuBd|xewsPd{ z376BfZZ7#0XuYG0DpE}4mjO;V>l)z3!oF7F;@S@&YA< zX|mR_%Hd7${52%5-25_l3>cpezML%Z4BSFau?%oiVk>s^rTsA0Kh*z7z1HKa(Y8KgWsz5Cz<2f5HJTmL1T%ZdluH$6 zUoCr$?@;L@+k(hL=tvNrYwe9q%ws>)SqxRJ9CNcg5iHOup literal 0 HcmV?d00001 diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index c4db97905..5bfbbbab8 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -99,6 +99,18 @@ class TestFilePng: if mode == "I;16": reloaded = reloaded.convert(mode) assert_image_equal(reloaded, im) + + def test_putpalette(self): + valid_file = "Tests/images/FudanPed00003_mask.png" + with pytest.raises(ValueError) as err: + mask = Image.open(valid_file) + mask.putpalette([ + 0, 0, 0, # black background + 255, 0, 0, # index 1 is red + 255, 255, 0, # index 2 is yellow + 255, 153, 0, # index 3 is orange + ]) + def test_invalid_file(self): invalid_file = "Tests/images/flower.jpg" From f64abb34037e81276c573de36b0b409514756c39 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 26 May 2023 07:54:54 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- Tests/test_file_png.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index 5bfbbbab8..a3669ef5a 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -99,18 +99,27 @@ class TestFilePng: if mode == "I;16": reloaded = reloaded.convert(mode) assert_image_equal(reloaded, im) - + def test_putpalette(self): valid_file = "Tests/images/FudanPed00003_mask.png" with pytest.raises(ValueError) as err: mask = Image.open(valid_file) - mask.putpalette([ - 0, 0, 0, # black background - 255, 0, 0, # index 1 is red - 255, 255, 0, # index 2 is yellow - 255, 153, 0, # index 3 is orange - ]) - + mask.putpalette( + [ + 0, + 0, + 0, # black background + 255, + 0, + 0, # index 1 is red + 255, + 255, + 0, # index 2 is yellow + 255, + 153, + 0, # index 3 is orange + ] + ) def test_invalid_file(self): invalid_file = "Tests/images/flower.jpg" From fde49ea507558330ed77021f7bfc8b1f13f916cb Mon Sep 17 00:00:00 2001 From: moghadas76 Date: Fri, 26 May 2023 07:57:58 +0000 Subject: [PATCH 3/3] Fix linting error --- Tests/test_file_png.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index a3669ef5a..720d2de21 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -102,7 +102,7 @@ class TestFilePng: def test_putpalette(self): valid_file = "Tests/images/FudanPed00003_mask.png" - with pytest.raises(ValueError) as err: + with pytest.raises(ValueError): mask = Image.open(valid_file) mask.putpalette( [