jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/306082 )
Change subject: Site.search: Search all namespaces when none is given ......................................................................
Site.search: Search all namespaces when none is given
This behavior matches what had been previously described in the docstring. Also remove the warning which was falsely triggered when the namespaces was 0. Amend the related test accordingly.
Change-Id: I49df0a1441ec976a474a3d05448b4d09ea932a60 --- M pywikibot/site.py M tests/site_tests.py 2 files changed, 2 insertions(+), 5 deletions(-)
Approvals: Lokal Profil: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py index 31cbebd..c317f8c 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -4498,11 +4498,8 @@ where = 'titles' else: where = 'title' - if namespaces == []: + if not namespaces and namespaces != 0: namespaces = [ns_id for ns_id in self.namespaces if ns_id >= 0] - if not namespaces: - pywikibot.warning(u"search: namespaces cannot be empty; using [0].") - namespaces = [0] srgen = self._generator(api.PageGenerator, type_arg="search", gsrsearch=searchstring, gsrwhat=where, namespaces=namespaces, diff --git a/tests/site_tests.py b/tests/site_tests.py index 82f1c0b..d95e41f 100644 --- a/tests/site_tests.py +++ b/tests/site_tests.py @@ -1377,7 +1377,7 @@ """Test the site.search() method.""" mysite = self.site try: - se = list(mysite.search("wiki", total=100)) + se = list(mysite.search("wiki", total=100, namespaces=0)) self.assertLessEqual(len(se), 100) self.assertTrue(all(isinstance(hit, pywikibot.Page) for hit in se))
pywikibot-commits@lists.wikimedia.org