[pygobject] tests: Update pixbuf loader test to not raise exception when closing



commit 16408a81713157cdf1e3b6bd74bd53e816e9dfda
Author: Simon Feltman <sfeltman src gnome org>
Date:   Sat Jan 3 17:20:14 2015 -0800

    tests: Update pixbuf loader test to not raise exception when closing
    
    GdkPixbuf commit: https://git.gnome.org/browse/gdk-pixbuf/commit/?id=447bd32650af
    changed the close() method to raise if the a loader is prematurely closed.
    Update the test to write a 1x1 PNG stream to ensure close() will succeed.

 tests/compat_test_pygtk.py |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/tests/compat_test_pygtk.py b/tests/compat_test_pygtk.py
index f0126c3..e947120 100644
--- a/tests/compat_test_pygtk.py
+++ b/tests/compat_test_pygtk.py
@@ -3,6 +3,7 @@
 
 import unittest
 import contextlib
+import base64
 
 from gi.repository import GLib
 
@@ -143,9 +144,17 @@ class TestGTKCompat(unittest.TestCase):
         gtk.gdk.Pixbuf()
 
     def test_pixbuf_loader(self):
+        # load a 1x1 pixel PNG from memory
+        data = base64.b64decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP4n8Dw'
+                                'HwAGIAJf85Z3XgAAAABJRU5ErkJggg==')
         loader = gtk.gdk.PixbufLoader('png')
+        loader.write(data)
         loader.close()
 
+        pixbuf = loader.get_pixbuf()
+        self.assertEqual(pixbuf.get_width(), 1)
+        self.assertEqual(pixbuf.get_height(), 1)
+
     def test_pixbuf_formats(self):
         formats = gtk.gdk.pixbuf_get_formats()
         self.assertEqual(type(formats[0]), dict)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]