Skip to content

test_set_reprs in test_pprint is fragile #53377

Closed

Description

@stutzbach
mannequin
BPO 9131
Nosy @rhettinger, @mdickinson
Files
  • issue9131.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 2010-09-21.21:09:08.524>
    created_at = <Date 2010-06-30.19:47:59.096>
    labels = ['type-bug', 'tests']
    title = 'test_set_reprs in test_pprint is fragile'
    updated_at = <Date 2010-09-21.21:09:08.522>
    user = 'https://bugs.python.org/stutzbach'

    bugs.python.org fields:

    activity = <Date 2010-09-21.21:09:08.522>
    actor = 'stutzbach'
    assignee = 'stutzbach'
    closed = True
    closed_date = <Date 2010-09-21.21:09:08.524>
    closer = 'stutzbach'
    components = ['Tests']
    creation = <Date 2010-06-30.19:47:59.096>
    creator = 'stutzbach'
    dependencies = []
    files = ['18593']
    hgrepos = []
    issue_num = 9131
    keywords = ['patch', 'needs review']
    message_count = 8.0
    messages = ['109008', '109016', '109018', '109020', '114451', '114473', '114474', '117100']
    nosy_count = 3.0
    nosy_names = ['rhettinger', 'mark.dickinson', 'stutzbach']
    pr_nums = []
    priority = 'low'
    resolution = 'accepted'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue9131'
    versions = ['Python 3.2']

    Activity

    1. stutzbach commented on Jun 30, 2010

      stutzbachmannequin
      MannequinAuthor

      test_set_reprs in test_pprint creates a complex arrangement of frozensets and tests the pretty-printed repr against a string hard-coded in the test. The hard-coded repr depends on the sort order of frozensets.

      However, "Since sets only define partial ordering (subset relationships), the output of the list.sort() method is undefined for lists of sets." (quoting http://docs.python.org/release/3.1/library/stdtypes.html#set-types-set-frozenset)

      In a nutshell, the test assumes frozenset({0}) will always sort before frozenset({1}), but:

      >>> frozenset({0}) < frozenset({1})
      False
      >>> frozenset({1}) < frozenset({0})
      False

      Consequently, this test is fragile. Small changes to Python's sort algorithm cause the test to fail when it should pass.

      I ran into this while playing with optimizations to the sort function, but I imagine other Python implementations will also run into trouble with this test.

    2. self-assigned this
      on Jun 30, 2010
    3. added
      tests
      on Jun 30, 2010
    4. mdickinson commented on Jun 30, 2010

      @mdickinson
      Member

      I agree that this looks a bit suspicious.

      Adding Raymond to the nosy list, since it looks like this is his code (r60264).

    5. rhettinger commented on Jun 30, 2010

      @rhettinger
      Contributor

      Yes, it's a fragile and crummy test.
      Feel free to delete it.

    6. rhettinger commented on Jun 30, 2010

      @rhettinger
      Contributor

      After discussion on #python-dev, have decided to mark the test as implementation specific and add a comment about why the test is fragile.

    7. stutzbach commented on Aug 20, 2010

      stutzbachmannequin
      MannequinAuthor

      How do we mark a test as implementation specific? Is there a decorator for that?

    8. stutzbach commented on Aug 21, 2010

      stutzbachmannequin
      MannequinAuthor

      Nevermind, I found it: @support.cpython_only

      I'll work on a patch to add the decorator and a comment about why the test is fragile.

    9. stutzbach commented on Aug 21, 2010

      stutzbachmannequin
      MannequinAuthor

      errr... ignore that first patch (now deleted)

      :-)

    10. stutzbach commented on Sep 21, 2010

      stutzbachmannequin
      MannequinAuthor

      Committed in r84961

    11. added
      type-bug
      on Sep 21, 2010
    12. 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

      teststype-bug

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions