MCPcopy
hub / github.com/encode/django-rest-framework / test_edit_choices

Method test_edit_choices

tests/test_fields.py:1985–1996  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1983 assert items[9].value == 'boolean'
1984
1985 def test_edit_choices(self):
1986 field = serializers.ChoiceField(
1987 allow_null=True,
1988 choices=[
1989 1, 2,
1990 ]
1991 )
1992 field.choices = [1]
1993 assert field.run_validation(1) == 1
1994 with pytest.raises(serializers.ValidationError) as exc_info:
1995 field.run_validation(2)
1996 assert exc_info.value.detail == ['"2" is not a valid choice.']
1997
1998 def test_enum_integer_choices(self):
1999 from enum import IntEnum

Callers

nothing calls this directly

Calls 1

run_validationMethod · 0.45

Tested by

no test coverage detected