我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用django.forms.widgets.Widget()。
def test_correct_error_thrown(self): from django.forms.widgets import Widget class NotARealWidget(Widget): def __repr__(self): return "NotARealWidget" class TestForm(forms.Form): not_a_real = forms.CharField(widget=NotARealWidget) expected = 'Could not find component "NotARealWidget"' with self.assertRaises(KeyError, msg=expected) as context: schema = Schema().render(TestForm(data={}))