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


Python EmptySearchQuerySet.exclude方法代码示例

本文整理汇总了Python中haystack.query.EmptySearchQuerySet.exclude方法的典型用法代码示例。如果您正苦于以下问题:Python EmptySearchQuerySet.exclude方法的具体用法?Python EmptySearchQuerySet.exclude怎么用?Python EmptySearchQuerySet.exclude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在haystack.query.EmptySearchQuerySet的用法示例。


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

示例1: EmptySearchQuerySetTestCase

# 需要导入模块: from haystack.query import EmptySearchQuerySet [as 别名]
# 或者: from haystack.query.EmptySearchQuerySet import exclude [as 别名]
class EmptySearchQuerySetTestCase(TestCase):
    def setUp(self):
        super(EmptySearchQuerySetTestCase, self).setUp()
        self.esqs = EmptySearchQuerySet()
    
    def test_get_count(self):
        self.assertEqual(self.esqs.count(), 0)
        self.assertEqual(len(self.esqs.all()), 0)
    
    def test_filter(self):
        sqs = self.esqs.filter(content='foo')
        self.assert_(isinstance(sqs, EmptySearchQuerySet))
        self.assertEqual(len(sqs), 0)
    
    def test_exclude(self):
        sqs = self.esqs.exclude(content='foo')
        self.assert_(isinstance(sqs, EmptySearchQuerySet))
        self.assertEqual(len(sqs), 0)
    
    def test_slice(self):
        sqs = self.esqs.filter(content='foo')
        self.assert_(isinstance(sqs, EmptySearchQuerySet))
        self.assertEqual(len(sqs), 0)
        self.assertEqual(sqs[:10], [])
        
        try:
            sqs[4]
            self.fail()
        except IndexError:
            pass
开发者ID:flebel,项目名称:django-haystack,代码行数:32,代码来源:query.py

示例2: EmptySearchQuerySetTestCase

# 需要导入模块: from haystack.query import EmptySearchQuerySet [as 别名]
# 或者: from haystack.query.EmptySearchQuerySet import exclude [as 别名]
class EmptySearchQuerySetTestCase(TestCase):
    def setUp(self):
        super(EmptySearchQuerySetTestCase, self).setUp()
        self.esqs = EmptySearchQuerySet()
    
    def test_get_count(self):
        self.assertEqual(self.esqs.count(), 0)
        self.assertEqual(len(self.esqs.all()), 0)
    
    def test_filter(self):
        sqs = self.esqs.filter(content='foo')
        self.assert_(isinstance(sqs, EmptySearchQuerySet))
        self.assertEqual(len(sqs), 0)
    
    def test_exclude(self):
        sqs = self.esqs.exclude(content='foo')
        self.assert_(isinstance(sqs, EmptySearchQuerySet))
        self.assertEqual(len(sqs), 0)
开发者ID:collin,项目名称:django-haystack,代码行数:20,代码来源:query.py

示例3: EmptySearchQuerySetTestCase

# 需要导入模块: from haystack.query import EmptySearchQuerySet [as 别名]
# 或者: from haystack.query.EmptySearchQuerySet import exclude [as 别名]
class EmptySearchQuerySetTestCase(TestCase):
    def setUp(self):
        super(EmptySearchQuerySetTestCase, self).setUp()
        self.esqs = EmptySearchQuerySet()

    def test_get_count(self):
        self.assertEqual(self.esqs.count(), 0)
        self.assertEqual(len(self.esqs.all()), 0)

    def test_filter(self):
        sqs = self.esqs.filter(content="foo")
        self.assertTrue(isinstance(sqs, EmptySearchQuerySet))
        self.assertEqual(len(sqs), 0)

    def test_exclude(self):
        sqs = self.esqs.exclude(content="foo")
        self.assertTrue(isinstance(sqs, EmptySearchQuerySet))
        self.assertEqual(len(sqs), 0)

    def test_slice(self):
        sqs = self.esqs.filter(content="foo")
        self.assertTrue(isinstance(sqs, EmptySearchQuerySet))
        self.assertEqual(len(sqs), 0)
        self.assertEqual(sqs[:10], [])

        try:
            sqs[4]
            self.fail()
        except IndexError:
            pass

    def test_dictionary_lookup(self):
        """
        Ensure doing a dictionary lookup raises a TypeError so
        EmptySearchQuerySets can be used in templates.
        """
        self.assertRaises(TypeError, lambda: self.esqs["count"])
开发者ID:antonyr,项目名称:django-haystack,代码行数:39,代码来源:test_query.py


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