schematics/schematics — pull request #259 by heewa (2014-11-22 06:56:34+00:00)
Title: give export loop to serializable when type has one

Otherwise serializable fields don't convert during `to_native()`. Test results without fix:

```python
_____________________________________________ test_serializable_with_model_to_native _____________________________________________

def test_serializable_with_model_to_native():
class ExperienceLevel(Model):
level = IntType()
title = StringType()

class Player(Model):
total_points = IntType()

@serializable(type=ModelType(ExperienceLevel))
def xp_level(self):
return ExperienceLevel(dict(level=self.total_points * 2, title="Best"))

player = Player({"total_points": 2})

assert player.xp_level.level == 4

d = player.to_native()
> assert d == {"total_points": 2, "xp_level": {"level": 4, "title": "Best"}}
E assert {'total_point...Level object>} == {'total_points...tle': 'Best'}}
E Omitting 1 identical items, use -v to show
E Differing items:
E {'xp_level': } != {'xp_level': {'level': 4, 'title': 'Best'}}
E Use -v to get the full diff

tests/test_serialize.py:136: AssertionError
```