MCPcopy Index your code
hub / github.com/encode/django-rest-framework / test_allow_null

Method test_allow_null

tests/test_fields.py:1941–1955  ·  view source on GitHub ↗

If `allow_null=True` then '' on HTML forms is treated as None.

(self)

Source from the content-addressed store, hash-verified

1939 assert output == ''
1940
1941 def test_allow_null(self):
1942 """
1943 If `allow_null=True` then '' on HTML forms is treated as None.
1944 """
1945 field = serializers.ChoiceField(
1946 allow_null=True,
1947 choices=[
1948 1, 2, 3
1949 ]
1950 )
1951 field.field_name = 'example'
1952 value = field.get_value(QueryDict('example='))
1953 assert value is None
1954 output = field.run_validation(None)
1955 assert output is None
1956
1957 def test_iter_options(self):
1958 """

Callers

nothing calls this directly

Calls 2

get_valueMethod · 0.45
run_validationMethod · 0.45

Tested by

no test coverage detected