def String(min_len=1, max_len=150):
     return Test([
         lambda v: text_type(v),
         validate(lambda v: len(v) >= min_len,
                  error='Not long enough.'),
         validate(lambda v: len(v) <= max_len,
                  error='Too long.'),
     ])
    def test_basics(self):
        test = Test([
            lambda v: text_type(v),
            validate(lambda v: len(v) >= 1, error='Not long enough.'),
            validate(lambda v: len(v) <= 10, error='Too long.'),
        ])

        assert test('Nils') == u'Nils'

        with raises(ValueError) as exc:
            test('')

        assert str(exc.value) == 'Not long enough.'