jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/440721 )
Change subject: Suppress ArgumentDeprecationWarning in test_immutable_namespaces_on_read ......................................................................
Suppress ArgumentDeprecationWarning in test_immutable_namespaces_on_read
Also fix the stacklevel in pagegenerators.GeneratorFactory._handle_namespaces.
Change-Id: Id93d28b7119afc0168fa86fe4a659dfcdc7b228c --- M pywikibot/pagegenerators.py M tests/pagegenerators_tests.py 2 files changed, 8 insertions(+), 2 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py index ab81b8d..9f7538c 100644 --- a/pywikibot/pagegenerators.py +++ b/pywikibot/pagegenerators.py @@ -835,7 +835,7 @@ if isinstance(self._namespaces, frozenset): warn('Cannot handle arg -namespaces as namespaces can not ' 'be altered after a generator is created.', - ArgumentDeprecationWarning, 2) + ArgumentDeprecationWarning, 3) return True if not value: value = pywikibot.input('What namespace are you filtering on?') diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py index bcc7afc..927a8a3 100755 --- a/tests/pagegenerators_tests.py +++ b/tests/pagegenerators_tests.py @@ -653,7 +653,13 @@ gf.handleArg('-ns:1,6') self.assertEqual(gf.namespaces, {1, 6}) self.assertIsInstance(gf.namespaces, frozenset) - gf.handleArg('-ns:0') + with suppress_warnings( + 'Cannot handle arg -namespaces as namespaces can not be altered ' + 'after a generator is created.', + pywikibot.exceptions.ArgumentDeprecationWarning + ): + gf.handleArg('-ns:0') + self.assertEqual(gf.namespaces, {1, 6})
def test_unsupported_quality_level_filter(self):
pywikibot-commits@lists.wikimedia.org