

def test_custom_lookup_exprs(self):
    filters.LOOKUP_TYPES = [('', '---------'), ('exact', 'Is equal to'), ('not_exact', 'Is not equal to'), ('lt', 'Lesser than'), ('gt', 'Greater than'), ('gte', 'Greater than or equal to'), ('lte', 'Lesser than or equal to'), ('startswith', 'Starts with'), ('endswith', 'Ends with'), ('contains', 'Contains'), ('not_contains', 'Does not contain')]
    f = Filter(lookup_expr=None)
    field = f.field
    choice_field = field.fields[1]
    all_choices = choice_field.choices
    self.assertIsInstance(field, LookupTypeField)
    self.assertEqual(all_choices, filters.LOOKUP_TYPES)
    self.assertEqual(all_choices[1][0], 'exact')
    self.assertEqual(all_choices[1][1], 'Is equal to')
    custom_f = Filter(lookup_expr=('endswith', 'not_contains'))
    custom_field = custom_f.field
    custom_choice_field = custom_field.fields[1]
    my_custom_choices = custom_choice_field.choices
    available_lookup_exprs = [('endswith', 'Ends with'), ('not_contains', 'Does not contain')]
    self.assertIsInstance(custom_field, LookupTypeField)
    self.assertEqual(my_custom_choices, available_lookup_exprs)
    self.assertEqual(my_custom_choices[0][0], 'endswith')
    self.assertEqual(my_custom_choices[0][1], 'Ends with')
    self.assertEqual(my_custom_choices[1][0], 'not_contains')
    self.assertEqual(my_custom_choices[1][1], 'Does not contain')

dataset/ETHPy150Open carltongibson/django-filter/tests/test_filters.py LookupTypesTests.test_custom_lookup_exprs/original