From ef3113d20abfc5bce23a26aec0c6dc7f0154d554 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Wed, 3 Jul 2019 15:42:48 +0930
Subject: [PATCH] TEST: Test different numbers of channels

---
 tests/test_bitmap.py | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/tests/test_bitmap.py b/tests/test_bitmap.py
index b59c4083e..81c1cd181 100644
--- a/tests/test_bitmap.py
+++ b/tests/test_bitmap.py
@@ -19,22 +19,27 @@ def test_bitmap():
 
     from PIL import Image
 
+    nchannels = (1, 3, 4)
+
     with tempdir.tempdir():
-        data = np.random.randint(0, 255, (100, 200, 4), dtype=np.uint8)
-        img  = Image.fromarray(data, mode='RGBA')
 
-        img.save('image.png')
+        for nch in nchannels:
+            data = np.random.randint(0, 255, (100, 200, nch), dtype=np.uint8)
+            img  = Image.fromarray(data.squeeze())
+
+            fname = 'image.png'
+            img.save(fname)
 
-        bmp = fslbmp.Bitmap('image.png')
+            bmp = fslbmp.Bitmap(fname)
 
-        assert bmp.name       == 'image.png'
-        assert bmp.dataSource == 'image.png'
-        assert bmp.shape      == (200, 100, 4)
+            assert bmp.name       == fname
+            assert bmp.dataSource == fname
+            assert bmp.shape      == (200, 100, nch)
 
-        repr(bmp)
-        hash(bmp)
+            repr(bmp)
+            hash(bmp)
 
-        assert np.all(bmp.data == np.fliplr(data.transpose(1, 0, 2)))
+            assert np.all(bmp.data == np.fliplr(data.transpose(1, 0, 2)))
 
 
 @pytest.mark.piltest
-- 
GitLab