From 45a616ef807219805613e3ab6c852d164b8267f2 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 18 Sep 2014 14:44:41 +0300 Subject: [PATCH 1/2] Created with Pillow: im = Image.open('hopper.jpg'); im = im.convert('1'); im.save('hopper.msp') --- Tests/images/hopper.msp | Bin 0 -> 2080 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Tests/images/hopper.msp diff --git a/Tests/images/hopper.msp b/Tests/images/hopper.msp new file mode 100644 index 0000000000000000000000000000000000000000..91d9a147ff0a7d2a27f89c66405e9011a464d359 GIT binary patch literal 2080 zcmXX{Z)jWB7609*XXn{2^vP|^=oo(1WELy)+QBwPH8!W5a}-@UlSkr0KD5&0 zg>`MRlGxX#Ep{2q(WDdt1y4v|UHLUx@zV!8)M}f-=qD%ZbAp^WPN0x^WYI>vq?v2& zys|6ly?f62oxk_oqwq_kF9-;*|9`x_w?g0k>g7Frvp?O=M1tPel0-MpnA_gIkSWEA znC{Xi%~QznSdMoGvh9E>!pF|3nPPMxo8y4iH&xwu{)*Mp!=q9nVnFowJ@^;5a@{?_ zhz`aA=BvwJlzJl3Y^Dg9x;S(DMfHB6*mHo#0ud-vpWOOyeJ2;nmU=>aC{FS7JB@lH zcE+-@nP;GPz4?cYo1ZnL><$*KAB2TEb91CoAHNbQMKgR~GvQAw%a@P-J!n~c;M8M# z46%q`|Mv0Ca(7Q;@6K}@{ZsWl59)pQvvb8z;o`1pRlL;xyV&5r^SM|dx3BZkv3%s7 z*uVH}!m@Hv|55QPf%on=*1y|*Fjxxx@abxO3Qt6yJRmYJM2lSCb?BNf0G0<2NFLOi zZylc%RE6Ux$OzT%Eba(~Nds!A6e{tcs-F~4b->7Q-W`OBOL-6p!L5SKX%IrFME1if zMN8b6(FK{KDj=2%<)TmsNi;#Iy0M&!@IciBGXSf|qa~e8g^?RjXB8gH$Rhd;2!)3# z^9V_qi>aP{R@o|71P_ru>FL#un;-7f1ZBfH+I5)a#*>%p zqrgP(q10T~BDpL*+}85_GuZceO64BsdOaZCV(afF+5(Zr1QoJV><@q<2p_p7qdia6o0zyX1LzN<>M+>GhHM!9H+S*!*rxOlm1H$Ay zaW$Q`Oh7AFMChT&_xJewLQ@vyV6@G#}RJ=oU8%=iS9cFB}*BX3Gud^|f^R zeYrMF_B1GEZg&r^mN`$_WKaE8ZFOPl?NpK&+*VCIwe$;l|Bc>?laLPAncjQj?knf5 zT$-oiZqn4SDl5{hgeo?P`K*DZ>sx;tTYL8nm-Dz?6@eSC1&Zan{2lVndET5z%@xojl?D;0rL7=5qmiUJa3ZL7_ zRchCct(cvX(zX*0chB2pO^&_a}p4Wlx86DSo;yP02hROQoq|m(v_tByh#|ig_TRNH-x@jV`o) z?h6&3oJXZ1%L#nY6PWWQ&3ESUl$&oJQ%f8ncX1| zZQRd)$q-+y+5RI@1HN1=cM5tN)r4(Q27R&^y-1C~(+)cV_(MZ*pFSpP%(wn229c$(|yDySFsC>hMD?f#{7(M z*gK~a7hj{F%4jlue?`z1&%h6zMi+W75M>$!)lD*p-PfRz9Wh}L+Ut!ue5KHN3*KgO z_lg3NsGScrsOF5;`m#=ZMc-eC=La1ZOiI(lc-@#Hb+oNORq4IFA?T@~)$>QIahu@N zn$dchycqc7_$+im{I^EDXr`1#RRg7uHp+*VuK}|khJmIPt+!7F`!Y;i8r01rM(5ZH z{9|+|F_RAHg4kDnnc)je`&%cevQ>O%eZ|0C`rkWf0!<_M(TQ!S6$OvUg*nZa#}PXY zGYR8GdG5H`w1PmTrs5csZ}3tVCPx$~bcupG!ZJpkH|s?OZHD=ObN%B%v{$_{>0}v~ vIoDN%c7g~hkxCEUH*4x%Wz?`~_K~Phz$6729)j+U@)2!>qEZc8JWcjLt-ix9 literal 0 HcmV?d00001 From 3bbfcb23aa0d32d1979806c0b34db3e7810ffd84 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 18 Sep 2014 14:48:07 +0300 Subject: [PATCH 2/2] More tests for MspImagePlugin.py --- Tests/helper.py | 6 +++--- Tests/test_file_msp.py | 24 +++++++++++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Tests/helper.py b/Tests/helper.py index 637e77f9c..34dafa645 100644 --- a/Tests/helper.py +++ b/Tests/helper.py @@ -191,11 +191,11 @@ def hopper(mode="RGB", cache={}): if mode == "RGB": im = Image.open("Tests/images/hopper.ppm") elif mode == "F": - im = lena("L").convert(mode) + im = hopper("L").convert(mode) elif mode[:4] == "I;16": - im = lena("I").convert(mode) + im = hopper("I").convert(mode) else: - im = lena("RGB").convert(mode) + im = hopper("RGB").convert(mode) # cache[mode] = im return im diff --git a/Tests/test_file_msp.py b/Tests/test_file_msp.py index a64faad10..2245f9ed6 100644 --- a/Tests/test_file_msp.py +++ b/Tests/test_file_msp.py @@ -1,15 +1,16 @@ -from helper import unittest, PillowTestCase, lena +from helper import unittest, PillowTestCase, hopper from PIL import Image +TEST_FILE = "Tests/images/hopper.msp" + class TestFileMsp(PillowTestCase): def test_sanity(self): - file = self.tempfile("temp.msp") - lena("1").save(file) + hopper("1").save(file) im = Image.open(file) im.load() @@ -17,6 +18,23 @@ class TestFileMsp(PillowTestCase): self.assertEqual(im.size, (128, 128)) self.assertEqual(im.format, "MSP") + def test_open(self): + # Arrange + # Act + im = Image.open(TEST_FILE) + + # Assert + self.assertEqual(im.size, (128, 128)) + self.assert_image_similar(im, hopper("1"), 4) + + def test_cannot_save_save_wrong_mode(self): + # Arrange + im = hopper() + file = self.tempfile("temp.msp") + + # Act/Assert + self.assertRaises(IOError, lambda: im.save(file)) + if __name__ == '__main__': unittest.main()