Skip to content

test_dictionary_is_unordered in about_dictionaries.py doesn't test what it says it tests #240

@jpretori

Description

@jpretori

I'm using Python 3.8.5.

According to official Python docs (https://docs.python.org/3.8/library/stdtypes.html#mapping-types-dict):

Changed in version 3.7: Dictionary order is guaranteed to be insertion order. This behavior was an implementation detail of CPython from 3.6.

So technically, in test_dictionary_is_unordered(), dict1 == dict2 should always return False. It doesn't for some reason I can't seem to work out.

Playing around with the Python console:

>>> d1
{1: 1, 2: 2, 3: 3}
>>> d2
{2: 2, 1: 1, 3: 3}
>>> d1 == d2
True
>>> l1
[1, 2, 3]
>>> l2
[2, 1, 3]
>>> l1 == l2
False

I guess maybe this means that == means something slightly different for dict than I expected?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions