Skip to content

Commit

Permalink
cleanup: Drop support for MediaWiki < 1.31
Browse files Browse the repository at this point in the history
Also update tests:
- use 'lobbypedia' instead of 'infogalactic' for logentries test
- remove unreachable sites from site_detect_tests

Bug: T378984
Change-Id: I9f33aa6e2ca8ebcda77b8e05ad45e62c66e24bc7
  • Loading branch information
xqt committed Dec 14, 2024
1 parent 53ee48e commit 042ea0c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
9 changes: 4 additions & 5 deletions pywikibot/site/_apisite.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
UnknownExtensionError,
)
from pywikibot.site._basesite import BaseSite
from pywikibot.site._decorators import need_right, need_version
from pywikibot.site._decorators import need_right
from pywikibot.site._extensions import (
EchoMixin,
FlowMixin,
Expand Down Expand Up @@ -1235,10 +1235,10 @@ def version(self) -> str:
pywikibot.error(msg)
raise

if MediaWikiVersion(version) < '1.27':
if MediaWikiVersion(version) < '1.31':
raise RuntimeError(f'Pywikibot "{pywikibot.__version__}" does not '
f'support MediaWiki "{version}".\n'
f'Use Pywikibot prior to "8.0" branch instead.')
f'support MediaWiki "{version}".\nUse '
f'Pywikibot prior to "10.0" branch instead.')
return version

@property
Expand Down Expand Up @@ -2746,7 +2746,6 @@ def protection_types(self) -> set[str]:
"""
return set(self.siteinfo.get('restrictions')['types'])

@need_version('1.27.3')
def protection_levels(self) -> set[str]:
"""Return the protection levels available on this site.
Expand Down
4 changes: 2 additions & 2 deletions pywikibot/site_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
SERVER_DB_ERROR_MSG = \
'<h1>Sorry! This site is experiencing technical difficulties.</h1>'

MIN_VERSION = MediaWikiVersion('1.27')
MIN_VERSION = MediaWikiVersion('1.31')


class MWSite:
Expand All @@ -40,7 +40,7 @@ def __init__(self, fromurl, **kwargs) -> None:
occurred while loading the site
:raises Timeout: a timeout occurred while loading the site
:raises RuntimeError: Version not found or version less than
1.27
1.31
"""
fromurl = removesuffix(fromurl, '$1')

Expand Down
8 changes: 8 additions & 0 deletions pywikibot/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,14 @@ def __str__(self) -> str:
"""Return version number with optional suffix."""
return '.'.join(str(v) for v in self.version) + self.suffix

def __repr__(self) -> str:
"""Return version number representation, mainly used by tests.
.. versionadded:: 10.0
"""
return f"'{self}'"

def __eq__(self, other: Any) -> bool:
if isinstance(other, str):
other = MediaWikiVersion(other)
Expand Down
21 changes: 10 additions & 11 deletions tests/logentries_tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""Test logentries module."""
"""Test :mod:`logentries` module."""
#
# (C) Pywikibot team, 2015-2023
# (C) Pywikibot team, 2015-2024
#
# Distributed under the terms of the MIT license.
#
Expand All @@ -28,11 +28,10 @@ class TestLogentriesBase(TestCase):

"""Base class for log entry tests.
It uses the German Wikipedia for a current representation of the
log entries and the test Wikipedia for the future representation.
It also tests on a wiki with MW <= 1.27 to check that the module
works with older wikis. It currently uses infogalacticwiki which as
of this commit uses 1.27.1.
It uses the German Wikipedia for a current representation of the log
entries and the test Wikipedia for the future representation. It
also tests on an older wiki to check that the module works with it.
It currently uses lobbypedia which as of this commit uses 1.31.6.
"""

sites = {
Expand All @@ -52,9 +51,9 @@ class TestLogentriesBase(TestCase):
'target': None,
},
'old': {
'family': AutoFamily('infogalactic',
'https://infogalactic.com/info/Main_Page'),
'code': 'en',
'family': AutoFamily('lobbypedia',
'https://lobbypedia.de/wiki/Hauptseite'),
'code': 'de',
'target': None,
}
}
Expand All @@ -65,7 +64,7 @@ def _get_logentry(self, logtype):
# This is an assertion as the tests don't make sense with newer
# MW versions and otherwise it might not be visible that the test
# isn't run on an older wiki.
self.assertEqual(self.site.mw_version, '1.27.1')
self.assertEqual(self.site.mw_version, '1.31.6')

with skipping(StopIteration,
msg=f'No entry found for {logtype!r}'):
Expand Down
7 changes: 1 addition & 6 deletions tests/site_detect_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,21 @@ class MediaWikiSiteTestCase(SiteDetectionTestCase):

non_standard_version_sites = (
'https://wiki.gentoo.org/wiki/$1',
'https://www.arabeyes.org/$1',
)

old_version_sites = (
'http://tfwiki.net/wiki/$1', # 1.19.5-1+deb7u1
'http://www.hrwiki.org/index.php/$1', # v 1.15.4
'http://www.thelemapedia.org/index.php/$1',
'http://www.werelate.org/wiki/$1',
'http://www.otterstedt.de/wiki/index.php/$1',
'https://en.wikifur.com/wiki/$1', # 1.23.16
'https://www.arabeyes.org/$1', # non standard 1.28.0
)

no_sites = (
'http://www.imdb.com/name/nm$1/',
'http://www.ecyrd.com/JSPWiki/Wiki.jsp?page=$1',
'http://www.tvtropes.org/pmwiki/pmwiki.php/Main/$1',
'http://c2.com/cgi/wiki?$1',
'https://phabricator.wikimedia.org/$1',
'http://www.merriam-webster.com/'
'cgi-bin/dictionary?book=Dictionary&va=$1',
'http://arxiv.org/abs/$1',
# looks like a MW site but isn't, api is redirected to
# https://foundation.wikimedia.org
Expand Down

0 comments on commit 042ea0c

Please sign in to comment.