Skip to content

Only the first field error is raised when parsing a Form #14

@cieplak

Description

@cieplak
class TestFormExceptions(TestCase):

    def test_exceptions(self):

        class DatingProfile(pilo.Form):

            genders = ['male', 'female', 'neutral']

            name = String()
            email = String()
            postal_code = String(length=5)
            blurb = String(max_length=100)
            gender = String(choices=genders)
            sexual_preferences = List(String(choices=genders))
            likes = List(String())

        # Two field errors
        DatingProfile(
            name='William Henry Cavendish III',
            email='whc@example.org',
            postal_code='9021',  # Invalid postal code
            blurb='I am a test fixture',
            gender='male',
            sexual_preferences=['female', 'neutral'],
            # Likes parameter missing
        )
======================================================================
ERROR: test_exceptions (tests.test_fields.TestFormExceptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pilo/tests/test_fields.py", line 424, in test_exceptions
    DatingProfile(**profile_params_with_two_errors)
  File "pilo/pilo/fields.py", line 1581, in __init__
    RaiseErrors()(*errors)
  File "pilo/pilo/fields.py", line 160, in __call__
    raise ex[0]
Invalid: postal_code - "9021" must have length >= 5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions