

def test_form_invalid_values(self):
    'Make sure only a few fields accept third option ("combine").'
    hidden = {
        'event_a': self.event_a.pk,
        'event_b': self.event_b.pk,
    }
    failing = {
        'id': 'combine',
        'slug': 'combine',
        'completed': 'combine',
        'assigned_to': 'combine',
        'start': 'combine',
        'end': 'combine',
        'host': 'combine',
        'administrator': 'combine',
        'url': 'combine',
        'reg_key': 'combine',
        'admin_fee': 'combine',
        'invoice_status': 'combine',
        'attendance': 'combine',
        'country': 'combine',
        'latitude': 'combine',
        'longitude': 'combine',
        'learners_pre': 'combine',
        'learners_post': 'combine',
        'instructors_pre': 'combine',
        'instructors_post': 'combine',
        'learners_longterm': 'combine',
    }
    passing = {
        'tags': 'combine',
        'contact': 'combine',
        'venue': 'combine',
        'address': 'combine',
        'notes': 'combine',
        'task_set': 'combine',
        'todoitem_set': 'combine',
    }
    data = hidden.copy()
    data.update(failing)
    data.update(passing)
    form = EventsMergeForm(data)
    self.assertFalse(form.is_valid())
    for key in failing:
        key.assertIn(key, form.errors)
    for key in passing:
        self.assertNotIn(key, form.errors)
    self.assertEqual(set(list(form.fields.keys())), set(list(data.keys())))

dataset/ETHPy150Open swcarpentry/amy/workshops/test/test_event.py TestEventMerging.test_form_invalid_values/VarMisuse@235/424 `self`->`key`