Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Mar 31, 2016
2 parents 930f7a4 + ebdb9b5 commit b4a21ca
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Revision History

## 0.7.2 (2016/03/30)

- Now preserving order of `attr` decorators on `Dictionary` converters.

## 0.7.1 (2016/03/30)

- Updated `String` to fetch `true` and `false` as strings.
Expand Down
15 changes: 15 additions & 0 deletions tests/test_ordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@
from . import strip


@yorm.attr(status=yorm.types.Boolean)
@yorm.attr(label=yorm.types.String)
class StatusDictionary(yorm.types.Dictionary):
"""Sample dictionary converter with ordered attributes."""


@yorm.attr(string=yorm.types.String)
@yorm.attr(number_int=yorm.types.Integer)
@yorm.attr(dictionary=StatusDictionary)
@yorm.attr(number_real=yorm.types.Float)
@yorm.attr(truthy=yorm.types.Boolean)
@yorm.attr(falsey=yorm.types.Boolean)
Expand All @@ -25,10 +32,14 @@ def test_attribute_order_is_maintained(tmpdir):
sample.number_real = 4.2
sample.truthy = False
sample.falsey = True
sample.dictionary['status'] = 1

expect(sample.__mapper__.text) == strip("""
string: Hello, world!
number_int: 42
dictionary:
status: true
label: ''
number_real: 4.2
truthy: false
falsey: true
Expand All @@ -44,13 +55,17 @@ def test_existing_files_are_reorderd(tmpdir):
number_real: 3
string: 4
truthy: 5
dictionary: {label: foo}
"""))
sample = Sample()
sample.falsey = 0

expect(sample.__mapper__.text) == strip("""
string: 4
number_int: 2
dictionary:
status: false
label: foo
number_real: 3.0
truthy: true
falsey: false
Expand Down
2 changes: 1 addition & 1 deletion yorm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

__project__ = 'YORM'
__version__ = '0.7.1'
__version__ = '0.7.2'

VERSION = __project__ + '-' + __version__

Expand Down
3 changes: 1 addition & 2 deletions yorm/types/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ def to_data(cls, value):
value2 = cls.create_default()
value2.update_value(value, strict=True)

data = {}

data = common.attrs[cls].__class__()
for name, converter in common.attrs[cls].items():
data[name] = converter.to_data(value2.get(name, None))

Expand Down

0 comments on commit b4a21ca

Please sign in to comment.