'Tests the AlterField operation.'

def test_alter_field(self):

    project_state = self.set_up_test_model('test_alfl')
    operation = migrations.AlterField('Pony', 'pink', models.IntegerField(null=True))
    self.assertEqual(operation.describe(), 'Alter    field    pink    on    Pony')
    new_state = project_state.clone()
    operation.state_forwards('test_alfl', new_state)
    self.assertIs(project_state.models[('test_alfl', 'pony')].get_field_by_name('pink').null, False)
    self.assertIs(new_state.models[('test_alfl', 'pony')].get_field_by_name('pink').null, True)
    self.assertColumnNotNull('test_alfl_pony', 'pink')
    with connection.schema_editor() as editor:
        operation.database_forwards('test_alfl', editor, project_state, new_state)
    self.assertColumnNull('test_alfl_pony', 'pink')
    with connection.schema_editor() as editor:
        operation.database_backwards('test_alfl', editor, new_state, project_state)
    self.assertColumnNotNull('test_alfl_pony', 'pink')
    definition = operation.deconstruct()
    self.assertEqual(definition[0], 'AlterField')
    self.assertEqual(definition[1], [])
    self.assertEqual(sorted(definition[2]), ['field', 'model_name', 'name'])
