def assertFieldOutput(self, fieldclass, valid, invalid, field_args=None,<EOL>field_kwargs=None, empty_value='<STR_LIT>'):
if field_args is None:<EOL><INDENT>field_args = []<EOL><DEDENT>if field_kwargs is None:<EOL><INDENT>field_kwargs = {}<EOL><DEDENT>required = fieldclass(*field_args, **field_kwargs)<EOL>optional = fieldclass(*field_args,<EOL>**dict(field_kwargs, required=False, allow_blank=True))<EOL>for input, output in valid.items():<EOL><INDENT>self.assertEqual(required.run_validation(input), output)<EOL>self.assertEqual(optional.run_validation(input), output)<EOL><DEDENT>for input, errors in invalid.items():<EOL><INDENT>with self.assertRaises(ValidationError) as context_manager:<EOL><INDENT>required.run_validation(input)<EOL><DEDENT>self.assertEqual(context_manager.exception.detail, errors)<EOL><DEDENT>if issubclass(fieldclass, CharField):<EOL><INDENT>field_kwargs.update({'<STR_LIT>': <NUM_LIT:2>, '<STR_LIT:max_length>': <NUM_LIT:20>})<EOL>self.assertIsInstance(fieldclass(*field_args, **field_kwargs),<EOL>fieldclass)<EOL><DEDENT>
Asserts that a form field behaves correctly with various inputs.
Args:
    fieldclass: the class of the field to be tested.
    valid: a dictionary mapping valid inputs to their expected
            clean values.
    invalid: a dictionary mapping invalid inputs to one or more
            raised error messages.
    field_args: the args passed to instantiate the field
    field_kwargs: the kwargs passed to instantiate the field
    empty_value: the expected run_validation output for inputs in empty_values