jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] allpages: Issue deprecation warning ......................................................................
[IMPROV] allpages: Issue deprecation warning
When an outdated value (aka not None, False or True) is used it's issuing a deprecation warning with the old and new value.
Change-Id: I23d3bac5c29e5149d29ae3f81878440ae48c5df7 --- M pywikibot/site.py M tests/site_tests.py 2 files changed, 15 insertions(+), 0 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py index a1eece9..f1901da 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -3539,6 +3539,7 @@ """ # backward compatibility test if filterredir not in (True, False, None): + old = filterredir if filterredir: if filterredir == 'only': filterredir = True @@ -3546,6 +3547,8 @@ filterredir = None else: filterredir = False + warn('The value "{0!r}" for "filterredir" is deprecated, use ' + '{1} instead.'.format(old, filterredir), DeprecationWarning, 3)
apgen = self._generator(api.PageGenerator, type_arg="allpages", namespaces=namespace, diff --git a/tests/site_tests.py b/tests/site_tests.py index 1781052..a43d5b4 100644 --- a/tests/site_tests.py +++ b/tests/site_tests.py @@ -102,6 +102,18 @@ self.assertIn('statistics', self.site.siteinfo('statistics', dump=True)) self.assertDeprecation('Calling siteinfo is deprecated, use itself instead.')
+ def test_allpages_filterredir_True(self): + """Test that filterredir set to 'only' is deprecated to True.""" + for page in self.site.allpages(filterredir='only', total=1): + self.assertTrue(page.isRedirectPage()) + self.assertDeprecation() + + def test_allpages_filterredir_False(self): + """Test that if filterredir's bool is False it's deprecated to False.""" + for page in self.site.allpages(filterredir='', total=1): + self.assertFalse(page.isRedirectPage()) + self.assertDeprecation() +
class TestSiteDryDeprecatedFunctions(DefaultDrySiteTestCase, DeprecationTestCase):
pywikibot-commits@lists.wikimedia.org