summaryrefslogtreecommitdiff
path: root/tests/test_search.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_search.py')
-rw-r--r--tests/test_search.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_search.py b/tests/test_search.py
new file mode 100644
index 000000000..3dd043bc7
--- /dev/null
+++ b/tests/test_search.py
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+"""
+ test_search
+ ~~~~~~~~~~~
+
+ Test the search index builder.
+
+ :copyright: Copyright 2007-2009 by the Sphinx team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+from docutils import frontend, utils, nodes
+from docutils.parsers import rst
+
+from sphinx.search import IndexBuilder
+
+
+def setup_module():
+ global settings, parser
+ optparser = frontend.OptionParser(components=(rst.Parser,))
+ settings = optparser.get_default_values()
+ parser = rst.Parser()
+
+
+FILE_CONTENTS = '''\
+.. test that comments are not indexed: boson
+
+test that non-comments are indexed: fermion
+'''
+
+def test_wordcollector():
+ doc = utils.new_document('test data', settings)
+ doc['file'] = 'dummy'
+ parser.parse(FILE_CONTENTS, doc)
+
+ ix = IndexBuilder(None)
+ ix.feed('filename', 'title', doc)
+ assert 'boson' not in ix._mapping
+ assert 'fermion' in ix._mapping