コード例 #1
0
 def test_value_from_datadict_subwidgets_name(self):
     widget = MultiWidget(widgets={"x": TextInput(), "": TextInput()})
     tests = [
         ({}, [None, None]),
         ({
             "field": "x"
         }, [None, "x"]),
         ({
             "field_x": "y"
         }, ["y", None]),
         ({
             "field": "x",
             "field_x": "y"
         }, ["y", "x"]),
     ]
     for data, expected in tests:
         with self.subTest(data):
             self.assertEqual(
                 widget.value_from_datadict(data, {}, "field"),
                 expected,
             )
コード例 #2
0
 def test_value_from_datadict_subwidgets_name(self):
     widget = MultiWidget(widgets={'x': TextInput(), '': TextInput()})
     tests = [
         ({}, [None, None]),
         ({
             'field': 'x'
         }, [None, 'x']),
         ({
             'field_x': 'y'
         }, ['y', None]),
         ({
             'field': 'x',
             'field_x': 'y'
         }, ['y', 'x']),
     ]
     for data, expected in tests:
         with self.subTest(data):
             self.assertEqual(
                 widget.value_from_datadict(data, {}, 'field'),
                 expected,
             )