Rev 2439: HelpContexts.search now returns the found topics. in file:///home/robertc/source/baz/help-contexts/
Robert Collins
robertc at robertcollins.net
Fri Apr 20 01:34:09 BST 2007
At file:///home/robertc/source/baz/help-contexts/
------------------------------------------------------------
revno: 2439
revision-id: robertc at robertcollins.net-20070420003403-0055vwwp20sdtpti
parent: robertc at robertcollins.net-20070420003040-6410f4x7k68hsx87
committer: Robert Collins <robertc at robertcollins.net>
branch nick: help-contexts
timestamp: Fri 2007-04-20 10:34:03 +1000
message:
HelpContexts.search now returns the found topics.
modified:
bzrlib/help.py help.py-20050505025907-4dd7a6d63912f894
bzrlib/tests/test_help.py test_help.py-20070419045354-6q6rq15j9e2n5fna-1
=== modified file 'bzrlib/help.py'
--- a/bzrlib/help.py 2007-04-20 00:30:40 +0000
+++ b/bzrlib/help.py 2007-04-20 00:34:03 +0000
@@ -196,9 +196,12 @@
:param topic: A string naming the help topic to search for.
:raises: NoHelpTopic if none of the contexts in search_path have topic.
+ :return: A list of HelpTopics which matched 'topic'.
"""
result = []
for context in self.search_path:
result.extend(context.get_topics(topic))
if not result:
raise errors.NoHelpTopic(topic)
+ else:
+ return result
=== modified file 'bzrlib/tests/test_help.py'
--- a/bzrlib/tests/test_help.py 2007-04-20 00:30:40 +0000
+++ b/bzrlib/tests/test_help.py 2007-04-20 00:34:03 +0000
@@ -105,3 +105,14 @@
('get_topics', '2', 'bar'),
],
calls)
+
+ def test_search_returns_context_results(self):
+ """Searching should return all the help topics found."""
+ class CannedContext(object):
+ def __init__(self, search_result):
+ self.result = search_result
+ def get_topics(self, topic):
+ return self.result
+ contexts = help.HelpContexts()
+ contexts.search_path = [CannedContext(['a']), CannedContext(['b', 'c'])]
+ self.assertEqual(['a', 'b', 'c'], contexts.search(None))
More information about the bazaar-commits
mailing list