Skip to content
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

Closed
terryjreedy opened this issue Jan 13, 2019 · 14 comments
Closed

IDLE: Fix squeezer test_reload. #79911

terryjreedy opened this issue Jan 13, 2019 · 14 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@terryjreedy
Copy link
Member

BPO 35730
Nosy @terryjreedy, @vstinner, @taleinat, @csabella, @miss-islington
PRs
  • bpo-35730: Disable IDLE test_reload assertion. #11543
  • [3.7] bpo-35730: Disable IDLE test_reload assertion. (GH-11543) #11544
  • bpo-35730: Use known good font in IDLE test_sqeezer #11552
  • bpo-35730: IDLE - test squeezer reload() by checking load_font() #11585
  • [3.7] bpo-35730: IDLE - test squeezer reload() by checking load_font() (GH-11585) #11601
  • 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:

    assignee = 'https://github.com/terryjreedy'
    closed_at = <Date 2019-01-18.06:54:15.280>
    created_at = <Date 2019-01-13.17:22:41.348>
    labels = ['3.8', 'expert-IDLE', 'type-bug', '3.7']
    title = 'IDLE: Fix squeezer test_reload.'
    updated_at = <Date 2019-01-18.06:54:15.279>
    user = 'https://github.com/terryjreedy'

    bugs.python.org fields:

    activity = <Date 2019-01-18.06:54:15.279>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2019-01-18.06:54:15.280>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2019-01-13.17:22:41.348>
    creator = 'terry.reedy'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35730
    keywords = ['patch', 'patch', 'patch']
    message_count = 14.0
    messages = ['333558', '333560', '333561', '333562', '333564', '333577', '333593', '333595', '333596', '333597', '333601', '333933', '333934', '333947']
    nosy_count = 5.0
    nosy_names = ['terry.reedy', 'vstinner', 'taleinat', 'cheryl.sabella', 'miss-islington']
    pr_nums = ['11543', '11544', '11552', '11585', '11601']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue35730'
    versions = ['Python 3.7', 'Python 3.8']

    @terryjreedy
    Copy link
    Member Author

    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.

    @terryjreedy terryjreedy added 3.7 (EOL) end of life 3.8 only security fixes labels Jan 13, 2019
    @terryjreedy terryjreedy self-assigned this Jan 13, 2019
    @terryjreedy terryjreedy added topic-IDLE type-bug An unexpected behavior, bug, or error labels Jan 13, 2019
    @terryjreedy
    Copy link
    Member Author

    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?

    @terryjreedy
    Copy link
    Member Author

    New changeset 5bb146a by Terry Jan Reedy in branch 'master':
    bpo-35730: Disable IDLE test_reload assertion. (GH-11543)
    5bb146a

    @miss-islington
    Copy link
    Contributor

    New changeset 890d3fa by Miss Islington (bot) in branch '3.7':
    bpo-35730: Disable IDLE test_reload assertion. (GH-11543)
    890d3fa

    @terryjreedy
    Copy link
    Member Author

    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).

    @terryjreedy
    Copy link
    Member Author

    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.

    @vstinner
    Copy link
    Member

    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 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
    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)

    @taleinat
    Copy link
    Contributor

    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.

    @vstinner
    Copy link
    Member

    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?

    @taleinat
    Copy link
    Contributor

    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.

    @vstinner
    Copy link
    Member

    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)

    @terryjreedy
    Copy link
    Member Author

    New changeset e55cf02 by Terry Jan Reedy (Tal Einat) in branch 'master':
    bpo-35730: IDLE - test squeezer reload() by checking load_font() (GH-11585)
    e55cf02

    @miss-islington
    Copy link
    Contributor

    New changeset 237f864 by Miss Islington (bot) in branch '3.7':
    bpo-35730: IDLE - test squeezer reload() by checking load_font() (GH-11585)
    237f864

    @terryjreedy
    Copy link
    Member Author

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants