New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IDLE: Fix squeezer test_reload. #79911
Comments
PR 10454 for bpo-35196 added, among other things, more tests to test_squeezer.py. SqueezerTest.test_reload initially worked on Mac and personal Windows machines. It failed on Cheryl Sabella's personal Ubuntu machine because doubling the nominal font size did not necessarily exactly double the reported pixel size of '0'. This was easily fixed by testing only that the size increased. self.assertGreater(squeezer.zero_char_width, orig_zero_char_width) It failed on CI Linux and Windows machines because the pixel size did not increase at all. This was fixed for the CI machines by directly assigning a new font tuple to text['font'] instead of involving the idleConf machinery. However, after merging, it failed with the same error that previously occurred on the CI machines. AssertionError: 6 not greater than 6. The initial fix will be to disable the assertion. |
Victor, a particular test assert fails only on Gentoo bots (see above). Questions:
|
I just realized that the Gentoo bots where this failed are, last I knew, the only *nix bots with X installed. The non-Windows CI bots run the gui tests with an X simulator. So Gentoo might not be the only distribution where this would fail. Two debug prints that might help: the tk patch level (does Gentoo have something ancient?); the actual font and in particular the actual size resulting from ('Courier', 10/20). |
The corresponding 3.7 buildbots failed the same way, 6 not greater than 6, as the 3.8 buildbots. One reason I am suspicious that something weird is going on is the width of 6. On my system, the Courier 10 and Courier 20 0 widths are 10 and 20. The Times New Roman 0 width, on CI machines that failed, was 8 (to be doubled to 16). 6 seems too small for Courier 10 0. |
https://buildbot.python.org/all/#/builders/108/builds/895/steps/5/logs/stdio ====================================================================== Traceback (most recent call last):
File "/buildbot/buildarea/cpython/3.7.ware-gentoo-x86.installed/build/target/lib/python3.7/idlelib/idle_test/test_squeezer.py", line 310, in test_reload
self.assertGreater(squeezer.zero_char_width, orig_zero_char_width)
AssertionError: 6 not greater than 6
The pythoninfo step of the buildbot says: tkinter.TCL_VERSION: 8.6 -- The test pass (at revision 47bd777, before you disabled the test) on my Fedora 29. I enabled all test resources using "-u all". I have the same Tkinter version: $ ./python -m test -u all test_idle -m test_reload -v
== CPython 3.7.2+ (tags/v3.7.2-112-g47bd777022:47bd777022, Jan 14 2019, 10:12:33) [GCC 8.2.1 20181215 (Red Hat 8.2.1-6)]
== Linux-4.19.13-300.fc29.x86_64-x86_64-with-fedora-29-Twenty_Nine little-endian
== cwd: /home/vstinner/prog/python/master/build/test_python_3006
== CPU count: 8
== encodings: locale=UTF-8, FS=utf-8
Run tests sequentially
0:00:00 load avg: 1.23 [1/1] test_idle
test_reload (idlelib.idle_test.test_codecontext.CodeContextTest) ... ok
test_reload (idlelib.idle_test.test_squeezer.SqueezerTest)
Test the reload() class-method. ... ok Ran 2 tests in 0.069s OK == Tests result: SUCCESS == 1 test OK. Total duration: 1 sec 344 ms vstinner@apu$ make pythoninfo|grep ^tk -- The test rely on a specific font name and specific font size: maybe this specific font is not available. Instead of skipping the test, would it make same to accept that squeezer.zero_char_width does not change? I don't know IDLE nor the test. diff --git a/Lib/idlelib/idle_test/test_squeezer.py b/Lib/idlelib/idle_test/test_squeezer.py
index 7c28a107a9..0d4467af0a 100644
--- a/Lib/idlelib/idle_test/test_squeezer.py
+++ b/Lib/idlelib/idle_test/test_squeezer.py
@@ -307,7 +307,7 @@ class SqueezerTest(unittest.TestCase):
str(new_auto_squeeze_min_lines))
Squeezer.reload()
- self.assertGreater(squeezer.zero_char_width, orig_zero_char_width)
+ self.assertGreaterEqual(squeezer.zero_char_width, orig_zero_char_width)
self.assertEqual(squeezer.auto_squeeze_min_lines,
new_auto_squeeze_min_lines) |
Can you help by checking this? Is there another font known to be universally available?
Not really. This test, test_reload(), is specifically checking that the reload() function updates zero_char_width after font changes. |
What if the old and the new font have the same width? |
The font is set to Courier 10 in the test's setup, and it is then set to Courier 20 by the test before calling reload(). The zero character should certainly not have the same width in both cases. ISTM that indeed the font must be missing, or something of that sort. |
The test still pass on my Fedora 29 with: diff --git a/Lib/idlelib/idle_test/test_squeezer.py b/Lib/idlelib/idle_test/test_squeezer.py
index 71eccd3693..e026567789 100644
--- a/Lib/idlelib/idle_test/test_squeezer.py
+++ b/Lib/idlelib/idle_test/test_squeezer.py
@@ -114,7 +114,7 @@ class SqueezerTest(unittest.TestCase):
if root is None:
root = get_test_tk_root(self)
text_widget = Text(root)
- text_widget["font"] = ('Courier', 10)
+ text_widget["font"] = ('XXXX', 10)
text_widget.mark_set("iomark", "1.0")
return text_widget
@@ -300,7 +300,7 @@ class SqueezerTest(unittest.TestCase):
orig_auto_squeeze_min_lines = squeezer.auto_squeeze_min_lines
# Increase both font size and auto-squeeze-min-lines.
- text_widget["font"] = ('Courier', 20)
+ text_widget["font"] = ('XXXX', 20)
new_auto_squeeze_min_lines = orig_auto_squeeze_min_lines + 10
self.set_idleconf_option_with_cleanup(
'main', 'PyShell', 'auto-squeeze-min-lines',
@@ -309,7 +309,7 @@ class SqueezerTest(unittest.TestCase):
Squeezer.reload()
# The following failed on Gentoo buildbots. Issue title will be
# IDLE: Fix squeezer test_reload.
- #self.assertGreater(squeezer.zero_char_width, orig_zero_char_width)
+ self.assertGreater(squeezer.zero_char_width, orig_zero_char_width)
self.assertEqual(squeezer.auto_squeeze_min_lines,
new_auto_squeeze_min_lines) |
I looked at the non-green results on the buildbot grid and found one IDLE failure, which passed on retest. I opened bpo-35771 for this. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: