classification
Title: IDLE: Fix squeezer test_reload.
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: cheryl.sabella, miss-islington, taleinat, terry.reedy, vstinner
Priority: normal Keywords: patch, patch, patch

Created on 2019-01-13 17:22 by terry.reedy, last changed 2019-01-18 06:54 by terry.reedy. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 11543 merged terry.reedy, 2019-01-13 17:30
PR 11544 merged miss-islington, 2019-01-13 17:50
PR 11552 closed terry.reedy, 2019-01-14 12:34
PR 11585 merged taleinat, 2019-01-17 07:46
PR 11601 merged miss-islington, 2019-01-18 02:26
Messages (14)
msg333558 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-01-13 17:22
PR 10454 for #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.
msg333560 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-01-13 17:40
Victor, a particular test assert fails only on Gentoo bots (see above).  Questions:

1. Can we disable the assert only on those machines?

2. I sometimes see what look like debug prints in buildbot test logs.  Correct?  If so, stdout or stderr?
msg333561 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-01-13 17:50
New changeset 5bb146aaea1484bcc117ab6cb38dda39ceb5df0f by Terry Jan Reedy in branch 'master':
bpo-35730: Disable IDLE test_reload assertion. (GH-11543)
https://github.com/python/cpython/commit/5bb146aaea1484bcc117ab6cb38dda39ceb5df0f
msg333562 - (view) Author: miss-islington (miss-islington) Date: 2019-01-13 18:05
New changeset 890d3fa10c68af6306cf6b989b2133978e6e7a12 by Miss Islington (bot) in branch '3.7':
bpo-35730: Disable IDLE test_reload assertion. (GH-11543)
https://github.com/python/cpython/commit/890d3fa10c68af6306cf6b989b2133978e6e7a12
msg333564 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-01-13 19:24
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).
msg333577 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-01-14 01:09
The corresponding 3.7 buildbots failed the same way, 6 not greater than 6, as the 3.8 buildbots.
https://buildbot.python.org/all/#/builders/108/builds/895/steps/5/logs/stdio
https://buildbot.python.org/all/#/builders/115/builds/888/steps/4/logs/stdio

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.
msg333593 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-01-14 09:15
https://buildbot.python.org/all/#/builders/108/builds/895/steps/5/logs/stdio
https://buildbot.python.org/all/#/builders/115/builds/888/steps/4/logs/stdio

======================================================================
FAIL: test_reload (idlelib.idle_test.test_squeezer.SqueezerTest)
Test the reload() class-method.
----------------------------------------------------------------------
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


> 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 pythoninfo step of the buildbot says:

tkinter.TCL_VERSION: 8.6
tkinter.TK_VERSION: 8.6
tkinter.info_patchlevel: 8.6.8

--

The test pass (at revision 47bd7770229b5238a438703ee1d52da2e983ec9e, 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
Tests result: SUCCESS

vstinner@apu$ make pythoninfo|grep ^tk
tkinter.TCL_VERSION: 8.6
tkinter.TK_VERSION: 8.6
tkinter.info_patchlevel: 8.6.8

--

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)
msg333595 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2019-01-14 09:30
> The test rely on a specific font name and specific font size: maybe this specific font is not available.

Can you help by checking this? Is there another font known to be universally 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.

Not really. This test, test_reload(), is specifically checking that the reload() function updates zero_char_width after font changes.
msg333596 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-01-14 10:11
> 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?
msg333597 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2019-01-14 10:17
> 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.
msg333601 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-01-14 10:40
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)
msg333933 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-01-18 02:26
New changeset e55cf024cae203f63b4f78f1b21c1375fe424441 by Terry Jan Reedy (Tal Einat) in branch 'master':
bpo-35730: IDLE - test squeezer reload() by checking load_font() (GH-11585)
https://github.com/python/cpython/commit/e55cf024cae203f63b4f78f1b21c1375fe424441
msg333934 - (view) Author: miss-islington (miss-islington) Date: 2019-01-18 02:44
New changeset 237f864c905531b2da211bebc5f6109b0b797bac by Miss Islington (bot) in branch '3.7':
bpo-35730: IDLE - test squeezer reload() by checking load_font() (GH-11585)
https://github.com/python/cpython/commit/237f864c905531b2da211bebc5f6109b0b797bac
msg333947 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-01-18 06:54
I looked at the non-green results on the buildbot grid and found one IDLE failure, which passed on retest.  I opened #35771 for this.
History
Date User Action Args
2019-01-18 06:54:15terry.reedysetstatus: open -> closed
messages: + msg333947

keywords: patch, patch, patch
resolution: fixed
stage: patch review -> resolved
2019-01-18 06:36:43terry.reedysetpull_requests: - pull_request11321
2019-01-18 06:36:27terry.reedysetpull_requests: - pull_request11322
2019-01-18 02:44:13miss-islingtonsetmessages: + msg333934
2019-01-18 02:26:43miss-islingtonsetpull_requests: + pull_request11322
2019-01-18 02:26:34miss-islingtonsetpull_requests: + pull_request11321
2019-01-18 02:26:25miss-islingtonsetpull_requests: + pull_request11320
2019-01-18 02:26:15terry.reedysetmessages: + msg333933
2019-01-18 02:13:47terry.reedysetpull_requests: - pull_request11273
2019-01-18 02:13:29terry.reedysetpull_requests: - pull_request11274
2019-01-17 07:46:22taleinatsetpull_requests: + pull_request11274
2019-01-17 07:46:14taleinatsetpull_requests: + pull_request11273
2019-01-17 07:46:07taleinatsetpull_requests: + pull_request11272
2019-01-16 03:22:04terry.reedysetpull_requests: - pull_request11182
2019-01-16 03:21:45terry.reedysetpull_requests: - pull_request11183
2019-01-14 12:34:45terry.reedysetpull_requests: + pull_request11183
2019-01-14 12:34:34terry.reedysetpull_requests: + pull_request11182
2019-01-14 12:34:24terry.reedysetpull_requests: + pull_request11181
2019-01-14 10:40:32vstinnersetkeywords: patch, patch, patch

messages: + msg333601
2019-01-14 10:17:21taleinatsetkeywords: patch, patch, patch

messages: + msg333597
2019-01-14 10:11:35vstinnersetkeywords: patch, patch, patch

messages: + msg333596
2019-01-14 09:30:37taleinatsetkeywords: patch, patch, patch

messages: + msg333595
2019-01-14 09:15:08vstinnersetkeywords: patch, patch, patch

messages: + msg333593
2019-01-14 01:09:38terry.reedysetkeywords: patch, patch, patch

messages: + msg333577
2019-01-13 19:24:12terry.reedysetkeywords: patch, patch, patch
nosy: + cheryl.sabella
messages: + msg333564

2019-01-13 18:14:27terry.reedysetpull_requests: - pull_request11157
2019-01-13 18:05:52miss-islingtonsetnosy: + miss-islington
messages: + msg333562
2019-01-13 17:50:46miss-islingtonsetpull_requests: + pull_request11157
2019-01-13 17:50:42miss-islingtonsetpull_requests: + pull_request11156
2019-01-13 17:50:31terry.reedysetmessages: + msg333561
2019-01-13 17:40:49terry.reedysetkeywords: patch, patch, patch
nosy: + vstinner
messages: + msg333560

2019-01-13 17:31:30terry.reedysetpull_requests: - pull_request11155
2019-01-13 17:31:16terry.reedysetpull_requests: - pull_request11154
2019-01-13 17:30:32terry.reedysetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request11155
2019-01-13 17:30:27terry.reedysetkeywords: + patch
stage: needs patch -> needs patch
pull_requests: + pull_request11154
2019-01-13 17:30:23terry.reedysetkeywords: + patch
stage: needs patch -> needs patch
pull_requests: + pull_request11153
2019-01-13 17:22:41terry.reedycreate