Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cieplak opened this issue Jun 20, 2015 · 2 comments
Open

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

cieplak opened this issue Jun 20, 2015 · 2 comments

Comments

@cieplak
Copy link
Contributor

cieplak commented Jun 20, 2015

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='[email protected]',
            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
@cieplak
Copy link
Contributor Author

cieplak commented Jun 20, 2015

#15

@cieplak
Copy link
Contributor Author

cieplak commented Jun 20, 2015

Here is what the error looks like with PR #15:

======================================================================
ERROR: test_exceptions (tests.test_fields.TestFormExceptions2)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pilo/tests/test_fields.py", line 482, in test_exceptions
    sexual_preferences=['female', 'neutral'],
  File "pilo/pilo/fields.py", line 1570, in __init__
    RaiseErrors()(*errors)
  File "pilo/pilo/fields.py", line 148, in __call__
    raise FormError(*field_errors)
FormError: 
* Invalid: postal_code - "9021" must have length >= 5
* Missing: likes - missing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant