def test_include_countries_model_field(self):
        iban_model_field = IBANField(countries=self.include_countries)
        for input, output in self.include_countries_valid.items():
            self.assertEqual(iban_model_field.clean(input, None), output)

        # Invalid inputs for model field.
        for input, errors in self.include_countries_invalid.items():
            with self.assertRaises(ValidationError) as context_manager:
                iban_model_field.clean(input, None)
            self.assertEqual(context_manager.exception.messages, errors[::-1])
    def test_include_countries_model_field(self):
        iban_model_field = IBANField(countries=self.include_countries)
        for input, output in self.include_countries_valid.items():
            self.assertEqual(iban_model_field.clean(input, None), output)

        # Invalid inputs for model field.
        for input, errors in self.include_countries_invalid.items():
            with self.assertRaises(ValidationError) as context_manager:
                iban_model_field.clean(input, None)
            self.assertEqual(context_manager.exception.messages, errors[::-1])
    def test_model_field(self):
        iban_model_field = IBANField()
        for input, output in self.valid.items():
            self.assertEqual(iban_model_field.clean(input, None), output)

        # Invalid inputs for model field.
        for input, errors in self.invalid.items():
            with self.assertRaises(ValidationError) as context_manager:
                iban_model_field.clean(input, None)
            # We can't check against minimum length here :(
            if input == '123456':
                self.assertEqual(context_manager.exception.messages, errors[0:1])
            else:
                # The error messages for models are in a different order.
                self.assertEqual(context_manager.exception.messages, errors[::-1])
    def test_model_field(self):
        iban_model_field = IBANField()
        for input, output in self.valid.items():
            self.assertEqual(iban_model_field.clean(input, None), output)

        # Invalid inputs for model field.
        for input, errors in self.invalid.items():
            with self.assertRaises(ValidationError) as context_manager:
                iban_model_field.clean(input, None)
            # We can't check against minimum length here :(
            if input == '123456':
                self.assertEqual(context_manager.exception.messages, errors[0:1])
            else:
                # The error messages for models are in a different order.
                self.assertEqual(context_manager.exception.messages, errors[::-1])