def __init__(self, *args, **kwargs): kwargs.setdefault('default', []) kwargs.setdefault('encoders', []).append(builtin_encoders.List()) super(ListField, self).__init__( builtin_validators.List(*kwargs.get('inner_validators', [])), *args, **kwargs)
def test_should_return_a_list_of_encoded_models(self): users = [User(), User()] self.encoder = encoders.List(encoders.Model()) result = self.encoder(users) expect(result).to(equal([users[0].encode(), users[1].encode()]))
def setup(self): self.encoder = encoders.List()