Fix comments.

This commit is contained in:
Tin Tvrtkovic 2016-05-08 23:50:53 +02:00
parent cd80208187
commit 17a48c3bc3
3 changed files with 12 additions and 3 deletions

View File

@ -22,7 +22,9 @@ def asdict(inst, recurse=True, filter=None, dict_factory=dict):
value as the second argument.
:type filer: callable
:param dict_factory: A callable to produce dictionaries from.
:param dict_factory: A callable to produce dictionaries from. For example,
to produce ordered dictionaries instead of normal Python dictionaries,
pass in ``collections.OrderedDict``.
:type dict_factory: callable
:rtype: :class:`dict`

View File

@ -47,6 +47,9 @@ class TestSimpleClass(object):
def create_class(attrs):
"""
A helper function for Hypothesis to generate attrs classes.
"""
# What if we get more than len(string.ascii_lowercase) attributes?
return make_class('HypClass', dict(zip(string.ascii_lowercase, attrs)))

View File

@ -89,7 +89,9 @@ class TestAsDict(object):
@given(simple_classes, st.sampled_from([dict, OrderedDict]))
def test_roundtrip(self, cls, dict_factory):
"""Test roundtripping for Hypothesis-generated classes."""
"""
Test roundtripping for Hypothesis-generated classes.
"""
instance = cls()
dict_instance = asdict(instance, dict_factory=dict_factory)
@ -101,7 +103,9 @@ class TestAsDict(object):
@given(simple_classes)
def test_asdict_preserve_order(self, cls):
"""When dumping to OrderedDict, field order should be preserved."""
"""
Field order should be preserved when dumping to OrderedDicts.
"""
instance = cls()
dict_instance = asdict(instance, dict_factory=OrderedDict)