Skip to content

Error message formatting errors in int object unit-test script #69398

Closed

Description

@s-wakaba
mannequin
BPO 25211
Nosy @berkerpeksag, @vadmium
Files
  • test_long.py.patch: patch for Lib/test/test_long.py
  • subTest-long.patch
  • 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 = None
    closed_at = <Date 2015-09-26.00:14:58.913>
    created_at = <Date 2015-09-22.07:52:15.580>
    labels = ['type-bug', 'tests']
    title = 'Error message formatting errors in int object unit-test script'
    updated_at = <Date 2015-09-26.00:14:58.913>
    user = 'https://bugs.python.org/s-wakaba'

    bugs.python.org fields:

    activity = <Date 2015-09-26.00:14:58.913>
    actor = 'martin.panter'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-09-26.00:14:58.913>
    closer = 'martin.panter'
    components = ['Tests']
    creation = <Date 2015-09-22.07:52:15.580>
    creator = 's-wakaba'
    dependencies = []
    files = ['40543', '40559']
    hgrepos = []
    issue_num = 25211
    keywords = ['patch']
    message_count = 6.0
    messages = ['251291', '251297', '251472', '251473', '251504', '251625']
    nosy_count = 4.0
    nosy_names = ['s-wakaba', 'python-dev', 'berker.peksag', 'martin.panter']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue25211'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5', 'Python 3.6']

    Activity

    1. s-wakaba commented on Sep 22, 2015

      s-wakabamannequin
      MannequinAuthor

      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

    2. added
      testsTests in the Lib/test dir
      type-bugAn unexpected behavior, bug, or error
      on Sep 22, 2015
    3. vadmium commented on Sep 22, 2015

      @vadmium
      Member

      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))
    4. vadmium commented on Sep 24, 2015

      @vadmium
      Member

      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.

    5. python-dev commented on Sep 24, 2015

      python-devmannequin
      Mannequin

      New changeset e2f1f69d0618 by Martin Panter in branch '2.7':
      Issue bpo-25211: Fix error message code in test_long; patch from s-wakaba
      https://hg.python.org/cpython/rev/e2f1f69d0618

    6. berkerpeksag commented on Sep 24, 2015

      @berkerpeksag
      Member

      subTest-long.patch looks good to me. Thanks!

    7. python-dev commented on Sep 26, 2015

      python-devmannequin
      Mannequin

      New changeset 697781ff3b49 by Martin Panter in branch '3.4':
      Issue bpo-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 bpo-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 bpo-25211: Merge test_long from 3.5
      https://hg.python.org/cpython/rev/11ad44d4177f

    8. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions