jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1323806?usp=email )
Change subject: Remove DefaultDrySiteTest and replace it's usage wir dry = True
......................................................................
Remove DefaultDrySiteTest and replace it's usage wir dry = True
Bug: T434388
Change-Id: I60fa025885636fc669e9af666f984e4e5b98d6f3
---
M tests/api_tests.py
M tests/aspects.py
M tests/dry_api_tests.py
M tests/dry_site_tests.py
M tests/echo_tests.py
M tests/link_tests.py
M tests/login_tests.py
M tests/page_tests.py
M tests/patrolbot_tests.py
M tests/site_tests.py
M tests/siteinfo_tests.py
M tests/textlib_tests.py
12 files changed, 82 insertions(+), 54 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/tests/api_tests.py b/tests/api_tests.py
index 1eaa446..81d0fe4 100755
--- a/tests/api_tests.py
+++ b/tests/api_tests.py
@@ -21,7 +21,7 @@
from pywikibot.exceptions import APIError, NoUsernameError
from pywikibot.throttle import Throttle
from pywikibot.tools import suppress_warnings
-from tests.aspects import DefaultDrySiteTestCase, DefaultSiteTestCase, TestCase
+from tests.aspects import DefaultSiteTestCase, TestCase
from tests.utils import FakeLoginManager
@@ -45,10 +45,12 @@
self.assertEqual(req.site, self.get_site())
-class TestDryApiFunctions(DefaultDrySiteTestCase):
+class TestDryApiFunctions(DefaultSiteTestCase):
"""API Request object test class."""
+ dry = True
+
def testObjectCreation(self) -> None:
"""Test api.Request() constructor."""
mysite = self.get_site()
@@ -346,10 +348,12 @@
options._set_site(self.get_site(), 'recentchanges', 'show')
-class TestDryOptionSet(DefaultDrySiteTestCase):
+class TestDryOptionSet(DefaultSiteTestCase):
"""OptionSet class test class."""
+ dry = True
+
def test_mutable_mapping(self) -> None:
"""Test keys, values and items from MutableMapping."""
options = api.OptionSet()
diff --git a/tests/aspects.py b/tests/aspects.py
index 6ff4c77..da6e793 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -1320,7 +1320,11 @@
class DefaultSiteTestCase(TestCase):
- """Run tests against the config specified site."""
+ """Run tests using the config specified site.
+
+ Set :attr:`dry` to ``True`` to run tests using the site in offline
+ (dry) mode.
+ """
family = config.family
code = config.mylang
@@ -1378,13 +1382,6 @@
pywikibot.config.mylang = site.code
-class DefaultDrySiteTestCase(DefaultSiteTestCase):
-
- """Run tests using the config specified site in offline mode."""
-
- dry = True
-
-
class WikimediaDefaultSiteTestCase(DefaultSiteTestCase):
"""Test class to run against a WMF site, preferring the default site."""
diff --git a/tests/dry_api_tests.py b/tests/dry_api_tests.py
index 3f0b19d..c78b022 100755
--- a/tests/dry_api_tests.py
+++ b/tests/dry_api_tests.py
@@ -8,6 +8,7 @@
from __future__ import annotations
import datetime
+import unittest
from pathlib import Path
from unittest.mock import patch
@@ -23,12 +24,7 @@
from pywikibot.login import LoginStatus
from pywikibot.tools import suppress_warnings
from tests import join_images_path
-from tests.aspects import (
- DefaultDrySiteTestCase,
- SiteAttributeTestCase,
- TestCase,
- unittest,
-)
+from tests.aspects import DefaultSiteTestCase, SiteAttributeTestCase, TestCase
class DryCachedRequestTests(SiteAttributeTestCase):
@@ -221,10 +217,12 @@
self.assertEqual(en_user_path, ar_user_path)
-class DryWriteAssertTests(DefaultDrySiteTestCase):
+class DryWriteAssertTests(DefaultSiteTestCase):
"""Test client site write assert."""
+ dry = True
+
def test_no_user(self) -> None:
"""Test Request object when not a user."""
self.site._userinfo = {}
@@ -287,10 +285,12 @@
self.assertNotEqual(body.find(file_content), -1)
-class ParamInfoDictTests(DefaultDrySiteTestCase):
+class ParamInfoDictTests(DefaultSiteTestCase):
"""Test extracting data from the ParamInfo."""
+ dry = True
+
#
https://en.wikipedia.org/w/api.php?action=paraminfo&modules=query+info|query+tokens
paraminfodata = {
'paraminfo': {
@@ -410,10 +410,12 @@
self.assertIn('login', param['type'])
-class QueryGenTests(DefaultDrySiteTestCase):
+class QueryGenTests(DefaultSiteTestCase):
"""Test QueryGenerator with a real site."""
+ dry = True
+
def test_query_constructor(self) -> None:
"""Test QueryGenerator constructor."""
q_gen1 = QueryGenerator(
diff --git a/tests/dry_site_tests.py b/tests/dry_site_tests.py
index 614b226..477c8ea 100755
--- a/tests/dry_site_tests.py
+++ b/tests/dry_site_tests.py
@@ -12,10 +12,10 @@
import pywikibot
from pywikibot.comms.http import user_agent, user_agent_username
from pywikibot.tools import suppress_warnings
-from tests.aspects import DefaultDrySiteTestCase
+from tests.aspects import DefaultSiteTestCase
-class TestDrySite(DefaultDrySiteTestCase):
+class TestDrySite(DefaultSiteTestCase):
"""Tests against a fake Site object."""
diff --git a/tests/echo_tests.py b/tests/echo_tests.py
index c980607..88527e7 100755
--- a/tests/echo_tests.py
+++ b/tests/echo_tests.py
@@ -12,10 +12,10 @@
import pywikibot
from pywikibot.echo import Notification
-from tests.aspects import DefaultDrySiteTestCase
+from tests.aspects import DefaultSiteTestCase
-class TestNotification(DefaultDrySiteTestCase):
+class TestNotification(DefaultSiteTestCase):
"""Test cases for Notification class."""
diff --git a/tests/link_tests.py b/tests/link_tests.py
index a042325..8e560d4 100755
--- a/tests/link_tests.py
+++ b/tests/link_tests.py
@@ -17,17 +17,19 @@
from pywikibot.site import Namespace
from tests.aspects import (
AlteredDefaultSiteTestCase,
- DefaultDrySiteTestCase,
+ DefaultSiteTestCase,
TestCase,
WikimediaDefaultSiteTestCase,
unittest,
)
-class TestCreateSeparated(DefaultDrySiteTestCase):
+class TestCreateSeparated(DefaultSiteTestCase):
"""Test ``Link.create_separated``."""
+ dry = True
+
def _test_link(self, link, page, section, label) -> None:
"""Test the separate contents of the link."""
self.assertIs(link.site, self.site)
@@ -57,7 +59,7 @@
# ---- Tests checking if the parser does (not) accept (in)valid titles
-class TestLink(DefaultDrySiteTestCase):
+class TestLink(DefaultSiteTestCase):
"""Test parsing links with DrySite.
@@ -67,6 +69,8 @@
namespaces.
"""
+ dry = True
+
def replaced(self, iterable):
"""Replace family specific title delimiter."""
for items in iterable:
@@ -213,10 +217,12 @@
self.assertEqual(abs_link.title, '/bar')
-class Issue10254TestCase(DefaultDrySiteTestCase):
+class Issue10254TestCase(DefaultSiteTestCase):
"""Test T102461 (Python issue 10254)."""
+ dry = True
+
def test_no_change(self) -> None:
"""Test T102461 (Python issue 10254) is not encountered."""
title = 'Li̍t-sṳ́'
diff --git a/tests/login_tests.py b/tests/login_tests.py
index 8c85b20..2304abc 100755
--- a/tests/login_tests.py
+++ b/tests/login_tests.py
@@ -21,7 +21,7 @@
from pywikibot.exceptions import NoUsernameError
from pywikibot.login import LoginManager
from pywikibot.tools import PYTHON_VERSION
-from tests.aspects import DefaultDrySiteTestCase
+from tests.aspects import DefaultSiteTestCase
class FakeFamily:
@@ -52,7 +52,7 @@
@mock.patch('pywikibot.Site', FakeSite)
@mock.patch('pywikibot.login.config', FakeConfig)
-class TestOfflineLoginManager(DefaultDrySiteTestCase):
+class TestOfflineLoginManager(DefaultSiteTestCase):
"""Test offline operation of login.LoginManager."""
@@ -89,10 +89,12 @@
@mock.patch('pywikibot.Site', FakeSite)
-class TestPasswordFile(DefaultDrySiteTestCase):
+class TestPasswordFile(DefaultSiteTestCase):
"""Test parsing password files."""
+ dry = True
+
def patch(self, name):
"""Patch up <name> in self.setUp."""
patcher = mock.patch(name)
diff --git a/tests/page_tests.py b/tests/page_tests.py
index 0660f19..d44b234 100755
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -10,6 +10,7 @@
import pickle
import re
import time
+import unittest
from contextlib import suppress
from datetime import timedelta
from unittest import mock
@@ -30,13 +31,7 @@
)
from pywikibot.tools import suppress_warnings
from tests import WARN_SITE_CODE, unittest_print
-from tests.aspects import (
- DefaultDrySiteTestCase,
- DefaultSiteTestCase,
- SiteAttributeTestCase,
- TestCase,
- unittest,
-)
+from tests.aspects import DefaultSiteTestCase, SiteAttributeTestCase, TestCase
from tests.utils import skipping
@@ -673,10 +668,12 @@
self.assertTrue(coord.primary)
-class TestPageGetFileHistory(DefaultDrySiteTestCase):
+class TestPageGetFileHistory(DefaultSiteTestCase):
"""Test the get_file_history method of the FilePage class."""
+ dry = True
+
def test_get_file_history_cache(self) -> None:
"""Test the cache mechanism of get_file_history."""
with mock.patch.object(self.site, 'loadimageinfo', autospec=True):
@@ -691,10 +688,12 @@
self.site.loadimageinfo.assert_called_once_with(page, history=True)
-class TestPageRepr(DefaultDrySiteTestCase):
+class TestPageRepr(DefaultSiteTestCase):
"""Test for Page's repr implementation."""
+ dry = True
+
@classmethod
def setUpClass(cls) -> None:
"""Initialize page instance."""
diff --git a/tests/patrolbot_tests.py b/tests/patrolbot_tests.py
index 5888f45..63315d3 100755
--- a/tests/patrolbot_tests.py
+++ b/tests/patrolbot_tests.py
@@ -11,7 +11,7 @@
from contextlib import suppress
from scripts.patrol import PatrolBot
-from tests.aspects import DefaultDrySiteTestCase
+from tests.aspects import DefaultSiteTestCase
DUMMY_PAGE_TUPLES = """
@@ -30,10 +30,12 @@
"""
-class TestPatrolBot(DefaultDrySiteTestCase):
+class TestPatrolBot(DefaultSiteTestCase):
"""Test the PatrolBot class."""
+ dry = True
+
def setUp(self) -> None:
"""Create a bot dummy instance."""
super().setUp()
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 6e6fd2b..3f8afe3 100755
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -28,7 +28,6 @@
)
from tests.aspects import (
AlteredDefaultSiteTestCase,
- DefaultDrySiteTestCase,
DefaultSiteTestCase,
DeprecationTestCase,
PatchingTestCase,
@@ -1116,10 +1115,11 @@
self.assertEqual(site.linktrail(), linktrail)
-class TestSingleCodeFamilySite(DefaultDrySiteTestCase):
+class TestSingleCodeFamilySite(TestCase):
"""Test single code family sites."""
+ dry = True
family = 'i18n'
code = 'i18n'
diff --git a/tests/siteinfo_tests.py b/tests/siteinfo_tests.py
index 2675861..96b6d61 100755
--- a/tests/siteinfo_tests.py
+++ b/tests/siteinfo_tests.py
@@ -15,7 +15,7 @@
import pywikibot
from pywikibot import async_request, page_put_queue
-from tests.aspects import DefaultDrySiteTestCase, DefaultSiteTestCase
+from tests.aspects import DefaultSiteTestCase
from tests.utils import entered_loop
@@ -98,10 +98,12 @@
self.assertNotIn('### key not in siteinfo ###', self.site.siteinfo)
-class TestSiteinfoDry(DefaultDrySiteTestCase):
+class TestSiteinfoDry(DefaultSiteTestCase):
"""Test Siteinfo in dry mode."""
+ dry = True
+
def test_siteinfo_timestamps(self) -> None:
"""Test that cache has the timestamp of CachedRequest."""
site = self.get_site()
diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py
index d6af780..6f1a9a0 100755
--- a/tests/textlib_tests.py
+++ b/tests/textlib_tests.py
@@ -22,7 +22,7 @@
from pywikibot.textlib import MultiTemplateMatchBuilder, extract_sections
from pywikibot.tools import has_module
from tests.aspects import (
- DefaultDrySiteTestCase,
+ DefaultSiteTestCase,
SiteAttributeTestCase,
TestCase,
require_modules,
@@ -131,10 +131,12 @@
textlib.interwikiFormat(interwikis, self.site))
-class TestFormatCategory(DefaultDrySiteTestCase):
+class TestFormatCategory(DefaultSiteTestCase):
"""Test category formatting."""
+ dry = True
+
catresult = '[[Category:Cat1]]\n[[Category:Cat2]]\n'
def test_category_format_raw(self) -> None:
@@ -164,10 +166,12 @@
textlib.categoryFormat(data, self.site))
-class TestAddText(DefaultDrySiteTestCase):
+class TestAddText(DefaultSiteTestCase):
"""Test add_text function."""
+ dry = True
+
def test_add_text(self) -> None:
"""Test adding text."""
self.assertEqual(
@@ -176,7 +180,7 @@
)
-class TestCategoryRearrangement(DefaultDrySiteTestCase):
+class TestCategoryRearrangement(DefaultSiteTestCase):
"""Ensure that sorting keys are not being lost.
@@ -184,6 +188,8 @@
newline and an empty string as separators.
"""
+ dry = True
+
old = '[[Category:Cat1]]\n[[Category:Cat2|]]\n' \
'[[Category:Cat1| ]]\n[[Category:Cat2|key]]'
@@ -625,10 +631,12 @@
self.assertEndsWith(m[0], 'foo {{bar}}')
-class TestDisabledParts(DefaultDrySiteTestCase):
+class TestDisabledParts(DefaultSiteTestCase):
"""Test the removeDisabledParts function in textlib."""
+ dry = True
+
def test_remove_disabled_parts(self) -> None:
"""Test removeDisabledParts function."""
tests = {
@@ -1017,10 +1025,12 @@
textlib.to_ascii_digits('២៩៩៧៩២៤៥៨', ['en']), '២៩៩៧៩២៤៥៨')
-class TestReplaceExcept(DefaultDrySiteTestCase):
+class TestReplaceExcept(DefaultSiteTestCase):
"""Test to verify the replacements with exceptions are done correctly."""
+ dry = True
+
def test_no_replace(self) -> None:
"""Test replacing when the old text does not match."""
self.assertEqual(textlib.replaceExcept('12345678', 'x', 'y', [],
@@ -1436,10 +1446,12 @@
r'X\g<bar>X')
-class TestMultiTemplateMatchBuilder(DefaultDrySiteTestCase):
+class TestMultiTemplateMatchBuilder(DefaultSiteTestCase):
"""Test MultiTemplateMatchBuilder."""
+ dry = True
+
@classmethod
def setUpClass(cls) -> None:
"""Cache namespace 10 (Template) case sensitivity."""
@@ -1529,10 +1541,12 @@
self.assertEqual(set(lang_links), self.sites_set - {self.site})
-class TestExtractSections(DefaultDrySiteTestCase):
+class TestExtractSections(DefaultSiteTestCase):
"""Test the extract_sections function."""
+ dry = True
+
def _extract_sections_tests(self, result, header, sections, footer='',
title='') -> None:
"""Test extract_sections function."""
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1323806?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: I60fa025885636fc669e9af666f984e4e5b98d6f3
Gerrit-Change-Number: 1323806
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[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]