当前位置: 首页>>代码示例>>Python>>正文


Python filters.Filter类代码示例

本文整理汇总了Python中django_filters.filters.Filter的典型用法代码示例。如果您正苦于以下问题:Python Filter类的具体用法?Python Filter怎么用?Python Filter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Filter类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_filter_using_action

 def test_filter_using_action(self):
     qs = mock.NonCallableMock(spec=[])
     action = mock.Mock(spec=['filter'])
     f = Filter(action=action)
     result = f.filter(qs, 'value')
     action.assert_called_once_with(qs, 'value')
     self.assertNotEqual(qs, result)
开发者ID:ArturFis,项目名称:django-filter,代码行数:7,代码来源:test_filters.py

示例2: test_filter_using_method

 def test_filter_using_method(self):
     qs = mock.NonCallableMock(spec=[])
     method = mock.Mock()
     f = Filter(method=method)
     result = f.filter(qs, 'value')
     method.assert_called_once_with(qs, None, 'value')
     self.assertNotEqual(qs, result)
开发者ID:msk7777,项目名称:django-filter,代码行数:7,代码来源:test_filters.py

示例3: test_filtering_skipped_with_list_value_with_blank_lookup

 def test_filtering_skipped_with_list_value_with_blank_lookup(self):
     return # Now field is required to provide valid lookup_type if it provides any
     qs = mock.Mock(spec=['filter'])
     f = Filter(name='somefield', lookup_type=None)
     result = f.filter(qs, Lookup('value', ''))
     qs.filter.assert_called_once_with(somefield__exact='value')
     self.assertNotEqual(qs, result)
开发者ID:ArturFis,项目名称:django-filter,代码行数:7,代码来源:test_filters.py

示例4: test_parent_unresolvable

    def test_parent_unresolvable(self):
        f = Filter(method='filter_f')
        with self.assertRaises(AssertionError) as w:
            f.filter(User.objects.all(), 0)

        self.assertIn("'None'", str(w.exception))
        self.assertIn('parent', str(w.exception))
        self.assertIn('filter_f', str(w.exception))
开发者ID:carltongibson,项目名称:django-filter,代码行数:8,代码来源:test_filterset.py

示例5: test_filter_using_action

    def test_filter_using_action(self):
        qs = mock.NonCallableMock(spec=[])
        action = mock.Mock(spec=['filter'])

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")

            f = Filter(action=action)
            result = f.filter(qs, 'value')
            action.assert_called_once_with(qs, 'value')
            self.assertNotEqual(qs, result)

            self.assertEqual(len(w), 1)
            self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
开发者ID:Elec,项目名称:django-filter,代码行数:14,代码来源:test_deprecations.py

示例6: test_filtering_uses_distinct

 def test_filtering_uses_distinct(self):
     qs = mock.Mock(spec=['filter', 'distinct'])
     f = Filter(name='somefield', distinct=True)
     f.filter(qs, 'value')
     result = qs.distinct.assert_called_once()
     self.assertNotEqual(qs, result)
开发者ID:ArturFis,项目名称:django-filter,代码行数:6,代码来源:test_filters.py

示例7: test_filtering_skipped_with_list_value_with_blank

 def test_filtering_skipped_with_list_value_with_blank(self):
     qs = mock.Mock()
     f = Filter(name='somefield', lookup_type=['some_lookup_type'])
     result = f.filter(qs, Lookup('', 'some_lookup_type'))
     self.assertListEqual(qs.method_calls, [])
     self.assertEqual(qs, result)
开发者ID:ArturFis,项目名称:django-filter,代码行数:6,代码来源:test_filters.py

示例8: test_filtering_with_list_value

 def test_filtering_with_list_value(self):
     qs = mock.Mock(spec=['filter'])
     f = Filter(name='somefield', lookup_type=['some_lookup_type'])
     result = f.filter(qs, Lookup('value', 'some_lookup_type'))
     qs.filter.assert_called_once_with(somefield__some_lookup_type='value')
     self.assertNotEqual(qs, result)
开发者ID:ArturFis,项目名称:django-filter,代码行数:6,代码来源:test_filters.py

示例9: test_filtering_skipped_with_none_value

 def test_filtering_skipped_with_none_value(self):
     qs = mock.Mock()
     f = Filter()
     result = f.filter(qs, None)
     self.assertListEqual(qs.method_calls, [])
     self.assertEqual(qs, result)
开发者ID:ArturFis,项目名称:django-filter,代码行数:6,代码来源:test_filters.py

示例10: test_filtering_uses_name

 def test_filtering_uses_name(self):
     qs = mock.Mock(spec=['filter'])
     f = Filter(name='somefield')
     f.filter(qs, 'value')
     result = qs.filter.assert_called_once_with(somefield__exact='value')
     self.assertNotEqual(qs, result)
开发者ID:ArturFis,项目名称:django-filter,代码行数:6,代码来源:test_filters.py

示例11: test_filtering_exclude

 def test_filtering_exclude(self):
     qs = mock.Mock(spec=['filter', 'exclude'])
     f = Filter(exclude=True)
     result = f.filter(qs, 'value')
     qs.exclude.assert_called_once_with(None__exact='value')
     self.assertNotEqual(qs, result)
开发者ID:ArturFis,项目名称:django-filter,代码行数:6,代码来源:test_filters.py

示例12: test_filtering

 def test_filtering(self):
     qs = mock.Mock(spec=['filter'])
     f = Filter()
     result = f.filter(qs, 'value')
     qs.filter.assert_called_once_with(None__exact='value')
     self.assertNotEqual(qs, result)
开发者ID:ArturFis,项目名称:django-filter,代码行数:6,代码来源:test_filters.py

示例13: test_filtering_skipped_with_list_value_with_blank_lookup

 def test_filtering_skipped_with_list_value_with_blank_lookup(self):
     qs = mock.Mock(spec=['filter'])
     f = Filter(name='somefield')
     result = f.filter(qs, ['value', ''])
     qs.filter.assert_called_once_with(somefield__exact='value')
     self.assertNotEqual(qs, result)
开发者ID:Kami,项目名称:django-filter,代码行数:6,代码来源:filter_tests.py


注:本文中的django_filters.filters.Filter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。