jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1332224?usp=email )

Change subject: delete: Clear cached reference table
......................................................................

delete: Clear cached reference table

Register _ref_table for cache invalidation so clear_cache discards stale 
references.

Change-Id: I7ccbb5c42e04e229145b29d31d0885d03171a561
---
M scripts/delete.py
M tests/deletionbot_tests.py
2 files changed, 15 insertions(+), 5 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/scripts/delete.py b/scripts/delete.py
index 0a82deb..4056eb3 100755
--- a/scripts/delete.py
+++ b/scripts/delete.py
@@ -82,11 +82,7 @@
     Supports the same interface as Page, with some added methods.
     """

-    def __init__(self, source, title: str = '', ns=0) -> None:
-        """Initializer."""
-        super().__init__(source, title, ns)
-        _cache_attrs = list(super()._cache_attrs)
-        _cache_attrs = tuple(_cache_attrs + ['_ref_table'])
+    _cache_attrs = (*Page._cache_attrs, '_ref_table')

     def get_ref_table(self, *args, **kwargs) -> RefTable:
         """Build mapping table with pages which links the current page."""
diff --git a/tests/deletionbot_tests.py b/tests/deletionbot_tests.py
index 30dbfa3..4aa8f2d 100755
--- a/tests/deletionbot_tests.py
+++ b/tests/deletionbot_tests.py
@@ -17,6 +17,20 @@
 from tests.utils import empty_sites


+class TestPageWithRefs(DefaultSiteTestCase):
+
+    """Test PageWithRefs."""
+
+    dry = True
+
+    def test_clear_ref_table_cache(self) -> None:
+        """Test that the reference table is cleared."""
+        page = delete.PageWithRefs(self.site, 'Main Page')
+        page._ref_table = {}
+        page.clear_cache()
+        self.assertNotHasAttr(page, '_ref_table')
+
+
 class TestDeletionBotWrite(ScriptMainTestCase):

     """Test deletionbot script."""

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1332224?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I7ccbb5c42e04e229145b29d31d0885d03171a561
Gerrit-Change-Number: 1332224
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Mpaa <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to