From 17a48c3bc300aaae6e2191e39c130147f74eb85b Mon Sep 17 00:00:00 2001 From: Tin Tvrtkovic Date: Sun, 8 May 2016 23:50:53 +0200 Subject: [PATCH] Fix comments. --- src/attr/_funcs.py | 4 +++- tests/__init__.py | 3 +++ tests/test_funcs.py | 8 ++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/attr/_funcs.py b/src/attr/_funcs.py index b2e049a2..57cde664 100644 --- a/src/attr/_funcs.py +++ b/src/attr/_funcs.py @@ -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` diff --git a/tests/__init__.py b/tests/__init__.py index 85e7bc92..f83e0a28 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -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))) diff --git a/tests/test_funcs.py b/tests/test_funcs.py index 06cf82db..b31e54e9 100644 --- a/tests/test_funcs.py +++ b/tests/test_funcs.py @@ -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)