This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Error message formatting errors in int object unit-test script
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.6, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: berker.peksag, martin.panter, python-dev, s-wakaba
Priority: normal Keywords: patch

Created on 2015-09-22 07:52 by s-wakaba, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_long.py.patch s-wakaba, 2015-09-22 07:52 patch for Lib/test/test_long.py
subTest-long.patch martin.panter, 2015-09-24 00:37 review
Messages (6)
msg251291 - (view) Author: (s-wakaba) Date: 2015-09-22 07:52
I've found some parts there are illegal message formatting in int object unit test script "Lib/test/test_long.py" when hacking the interpreter.

because they were an easy problem, I already fixed them to promote my work.
Therefore, the patch has been attacked.

thanks
msg251297 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-09-22 09:11
Thanks for the patch, it looks correct. The Frm class takes a variable number of *args, and then returns “format % args”. It should at least be applied to the 2.7 branch.

For 3.4+, perhaps we can eliminate the need for the Frm class altogether, by using TestCase.subTest():

def check_bitop_identities_1(self, x):
    eq = self.assertEqual
    with self.subTest(x=x):
        eq(x & 0, 0)
        ...
        for n in range(2*SHIFT):
            p2 = 2 ** n
            with self.subTest(n=n, p2=p2):
                eq(x << n >> n, x)
                ...
                eq(x & -p2, x & ~(p2 - 1))
msg251472 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-09-24 00:37
I will commit your patch to 2.7.

Here is a my alternative proposal for 3.4+, dropping the Frm class and using subTest() instead. I kept some error messages where I thought they added clarity, but dropped most because I thought they were redundant with the test code and subTest() parameters.

The test file takes a bit longer to run as a consequence of my patch (was 6.3 s, now 7.3 s). However I think the simpler and more maintainable code outweighs this.
msg251473 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-09-24 00:38
New changeset e2f1f69d0618 by Martin Panter in branch '2.7':
Issue #25211: Fix error message code in test_long; patch from s-wakaba
https://hg.python.org/cpython/rev/e2f1f69d0618
msg251504 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-09-24 09:58
subTest-long.patch looks good to me. Thanks!
msg251625 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-09-26 00:13
New changeset 697781ff3b49 by Martin Panter in branch '3.4':
Issue #25211: Eliminate lazy error message class by using subTest
https://hg.python.org/cpython/rev/697781ff3b49

New changeset 6e11708dcb3b by Martin Panter in branch '3.5':
Issue #25211: Merge test_long from 3.4 into 3.5
https://hg.python.org/cpython/rev/6e11708dcb3b

New changeset 11ad44d4177f by Martin Panter in branch 'default':
Issue #25211: Merge test_long from 3.5
https://hg.python.org/cpython/rev/11ad44d4177f
History
Date User Action Args
2022-04-11 14:58:21adminsetgithub: 69398
2015-09-26 00:14:58martin.pantersetstatus: open -> closed
resolution: fixed
stage: commit review -> resolved
2015-09-26 00:13:03python-devsetmessages: + msg251625
2015-09-24 09:58:03berker.peksagsetmessages: + msg251504
stage: patch review -> commit review
2015-09-24 00:39:00python-devsetnosy: + python-dev
messages: + msg251473
2015-09-24 00:37:43martin.pantersetfiles: + subTest-long.patch
nosy: + berker.peksag
messages: + msg251472

2015-09-22 09:11:04martin.pantersetversions: + Python 2.7, Python 3.4, Python 3.6
nosy: + martin.panter

messages: + msg251297

stage: patch review
2015-09-22 07:52:15s-wakabacreate