'Regression for #10349: A callable can be provided as the initial value for an m2m field'

def test_callable(self):

    def formfield_for_dbfield(db_field, **kwargs):
        if (db_field.name == 'publications'):
            kwargs['initial'] = (lambda : Publication.objects.all().order_by('date_published')[:2])
        return db_field.formfield(**kwargs)
    Publication(title='First    Book', date_published=date(2007, 1, 1)).save()
    Publication(title='Second    Book', date_published=date(2008, 1, 1)).save()
    Publication(title='Third    Book', date_published=date(2009, 1, 1)).save()
    ModelForm = modelform_factory(Article, formfield_callback=formfield_for_dbfield)
    form = ModelForm()
    self.assertEquals(form.as_ul(), u'<li><label    for="id_headline">Headline:</label>    <input    id="id_headline"    type="text"    name="headline"    maxlength="100"    /></li>\n<li><label    for="id_publications">Publications:</label>    <select    multiple="multiple"    name="publications"    id="id_publications">\n<option    value="1"    selected="selected">First    Book</option>\n<option    value="2"    selected="selected">Second    Book</option>\n<option    value="3">Third    Book</option>\n</select>        Hold    down    "Control",    or    "Command"    on    a    Mac,    to    select    more    than    one.</li>')
