-
Notifications
You must be signed in to change notification settings - Fork 55
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
ENH correctly restore default_factory of a defaultdict #433
Changes from 1 commit
c5336ed
ca649ae
1bb275c
4fe05f1
cfab777
f0a0e05
d118520
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
import operator | ||
import sys | ||
import warnings | ||
from collections import Counter, defaultdict | ||
from collections import Counter, OrderedDict, defaultdict | ||
from functools import partial, wraps | ||
from pathlib import Path | ||
from zipfile import ZIP_DEFLATED, ZipFile | ||
|
@@ -1092,3 +1092,10 @@ def test_defaultdict(): | |
obj_loaded = loads(dumps(obj)) | ||
assert obj_loaded == obj | ||
assert obj_loaded.default_factory == obj.default_factory | ||
|
||
|
||
@pytest.mark.parametrize("cls", [dict, OrderedDict]) | ||
def test_dictionary(cls): | ||
obj = cls({1: 5, 6: 3, 2: 4}) | ||
loaded_obj = loads(dumps(obj)) | ||
assert obj == loaded_obj | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the type also be checked? E.g. this passes: assert {2: 20, 1: 10} == OrderedDict([(2, 20), (1, 10)])
assert {1: 10, 2: 20} == OrderedDict([(2, 20), (1, 10)]) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ping @adrinjalali There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops, sorry. Added now @BenjaminBossan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should a test for
OrderedDict
be added too?