[pypy-commit] pypy stdlib-2.7.9: Fix more tkinter tests

amauryfa noreply at buildbot.pypy.org
Sun Jan 25 17:10:59 CET 2015


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: stdlib-2.7.9
Changeset: r75513:4360c70a0171
Date: 2015-01-24 22:47 +0100
http://bitbucket.org/pypy/pypy/changeset/4360c70a0171/

Log:	Fix more tkinter tests

diff --git a/lib-python/2.7/lib-tk/test/test_tkinter/test_images.py b/lib-python/2.7/lib-tk/test/test_tkinter/test_images.py
--- a/lib-python/2.7/lib-tk/test/test_tkinter/test_images.py
+++ b/lib-python/2.7/lib-tk/test/test_tkinter/test_images.py
@@ -37,6 +37,7 @@
         self.assertEqual(image.height(), 16)
         self.assertIn('::img::test', self.root.image_names())
         del image
+        support.gc_collect()
         self.assertNotIn('::img::test', self.root.image_names())
 
     def test_create_from_data(self):
@@ -51,6 +52,7 @@
         self.assertEqual(image.height(), 16)
         self.assertIn('::img::test', self.root.image_names())
         del image
+        support.gc_collect()
         self.assertNotIn('::img::test', self.root.image_names())
 
     def assertEqualStrList(self, actual, expected):
@@ -131,6 +133,7 @@
         self.assertEqual(image['file'], testfile)
         self.assertIn('::img::test', self.root.image_names())
         del image
+        support.gc_collect()
         self.assertNotIn('::img::test', self.root.image_names())
 
     def check_create_from_data(self, ext):
@@ -148,6 +151,7 @@
         self.assertEqual(image['file'], '')
         self.assertIn('::img::test', self.root.image_names())
         del image
+        support.gc_collect()
         self.assertNotIn('::img::test', self.root.image_names())
 
     def test_create_from_ppm_file(self):
diff --git a/lib-python/2.7/lib-tk/test/test_tkinter/test_variables.py b/lib-python/2.7/lib-tk/test/test_tkinter/test_variables.py
--- a/lib-python/2.7/lib-tk/test/test_tkinter/test_variables.py
+++ b/lib-python/2.7/lib-tk/test/test_tkinter/test_variables.py
@@ -1,4 +1,5 @@
 import unittest
+from test.test_support import gc_collect
 
 from Tkinter import Variable, StringVar, IntVar, DoubleVar, BooleanVar, Tcl, TclError
 
@@ -32,6 +33,7 @@
         v = Variable(self.root, "sample string", "varname")
         self.assertTrue(self.info_exists("varname"))
         del v
+        gc_collect()
         self.assertFalse(self.info_exists("varname"))
 
     def test_dont_unset_not_existing(self):
@@ -39,9 +41,11 @@
         v1 = Variable(self.root, name="name")
         v2 = Variable(self.root, name="name")
         del v1
+        gc_collect()
         self.assertFalse(self.info_exists("name"))
         # shouldn't raise exception
         del v2
+        gc_collect()
         self.assertFalse(self.info_exists("name"))
 
     def test___eq__(self):
diff --git a/lib_pypy/_tkinter/app.py b/lib_pypy/_tkinter/app.py
--- a/lib_pypy/_tkinter/app.py
+++ b/lib_pypy/_tkinter/app.py
@@ -539,6 +539,8 @@
         byte-array object.  Use it to pass binary data (e.g. image's
         data) to Tcl/Tk commands."""
         cdata = tkffi.new("char[]", buf)
-        obj = tklib.Tcl_NewByteArrayObj(cdata, len(buf))
-        return FromObj(self, obj)
+        res = tklib.Tcl_NewByteArrayObj(cdata, len(buf))
+        if not res:
+            self.raiseTclError()
+        return FromObj(self, res)
         


More information about the pypy-commit mailing list