mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
[3.9] bpo-25130: Add calls of gc.collect() in tests to support PyPy (GH-28005). (GH-28028)
(cherry picked from commit 2a8127cafe
)
This commit is contained in:
parent
dab74d68e3
commit
330aabbbbe
36 changed files with 143 additions and 15 deletions
|
@ -2,7 +2,7 @@ import sys
|
|||
import unittest
|
||||
import tkinter
|
||||
from tkinter import ttk
|
||||
from test.support import requires, run_unittest
|
||||
from test.support import requires, run_unittest, gc_collect
|
||||
from tkinter.test.support import AbstractTkTest, AbstractDefaultRootTest
|
||||
|
||||
requires('gui')
|
||||
|
@ -18,6 +18,7 @@ class LabeledScaleTest(AbstractTkTest, unittest.TestCase):
|
|||
x = ttk.LabeledScale(self.root)
|
||||
var = x._variable._name
|
||||
x.destroy()
|
||||
gc_collect() # For PyPy or other GCs.
|
||||
self.assertRaises(tkinter.TclError, x.tk.globalgetvar, var)
|
||||
|
||||
# manually created variable
|
||||
|
@ -30,6 +31,7 @@ class LabeledScaleTest(AbstractTkTest, unittest.TestCase):
|
|||
else:
|
||||
self.assertEqual(float(x.tk.globalgetvar(name)), myvar.get())
|
||||
del myvar
|
||||
gc_collect() # For PyPy or other GCs.
|
||||
self.assertRaises(tkinter.TclError, x.tk.globalgetvar, name)
|
||||
|
||||
# checking that the tracing callback is properly removed
|
||||
|
@ -171,6 +173,7 @@ class LabeledScaleTest(AbstractTkTest, unittest.TestCase):
|
|||
def test_resize(self):
|
||||
x = ttk.LabeledScale(self.root)
|
||||
x.pack(expand=True, fill='both')
|
||||
gc_collect() # For PyPy or other GCs.
|
||||
x.update()
|
||||
|
||||
width, height = x.master.winfo_width(), x.master.winfo_height()
|
||||
|
@ -206,6 +209,7 @@ class OptionMenuTest(AbstractTkTest, unittest.TestCase):
|
|||
optmenu.destroy()
|
||||
self.assertEqual(optmenu.tk.globalgetvar(name), var.get())
|
||||
del var
|
||||
gc_collect() # For PyPy or other GCs.
|
||||
self.assertRaises(tkinter.TclError, optmenu.tk.globalgetvar, name)
|
||||
|
||||
|
||||
|
@ -251,6 +255,7 @@ class OptionMenuTest(AbstractTkTest, unittest.TestCase):
|
|||
|
||||
# check that variable is updated correctly
|
||||
optmenu.pack()
|
||||
gc_collect() # For PyPy or other GCs.
|
||||
optmenu['menu'].invoke(0)
|
||||
self.assertEqual(optmenu._variable.get(), items[0])
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue