jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/833010 )
Change subject: [cleanup] Give up Python 2 compatiblity for setup.py
......................................................................
[cleanup] Give up Python 2 compatiblity for setup.py
Change-Id: I2b0fab10e2005bcad95b9a1268dd0666f4fb2683
---
M pwb.py
M setup.py
2 files changed, 12 insertions(+), 7 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pwb.py b/pwb.py
index bb8e0c5..d5cd0e9 100755
--- a/pwb.py
+++ b/pwb.py
@@ -473,6 +473,8 @@
# setup.py may also raise RuntimeError
except RuntimeError as e: # pragma: no cover
sys.exit(e)
+ except SyntaxError as e: # pragma: no cover
+ sys.exit(str(e) + '\nProbably outdated Python version')
if not execute():
print(__doc__)
diff --git a/setup.py b/setup.py
index 00a1cb9..fe66a45 100755
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,4 @@
#!/usr/bin/python3
-# -*- coding: utf-8 -*-
"""Installer script for Pywikibot framework.
**How to create a new distribution:**
@@ -25,11 +24,15 @@
#
# Distributed under the terms of the MIT license.
#
-# ## KEEP PYTHON 2 SUPPORT FOR THIS SCRIPT ## #
import os
import re
import sys
+if sys.version_info[:3] >= (3, 9):
+ List = list
+else:
+ from typing import List
+
VERSIONS_REQUIRED_MESSAGE = """
Pywikibot is not available on:
@@ -44,7 +47,7 @@
raise RuntimeError(VERSIONS_REQUIRED_MESSAGE.format(version=sys.version))
-def python_is_supported():
+def python_is_supported() -> bool:
"""Check that Python is supported."""
return sys.version_info[:3] >= (3, 5, 3)
@@ -147,7 +150,7 @@
assert metadata.__name__ == name
-def get_validated_version(): # pragma: no cover
+def get_validated_version() -> str: # pragma: no cover
"""Get a validated pywikibot module version string.
The version number from pywikibot.__metadata__.__version__ is used.
@@ -205,7 +208,7 @@
return version
-def read_desc(filename): # pragma: no cover
+def read_desc(filename) -> str: # pragma: no cover
"""Read long description.
Combine included restructured text files which must be done before
@@ -227,7 +230,7 @@
return ''.join(desc)
-def get_packages(name): # pragma: no cover
+def get_packages(name) -> List[str]: # pragma: no cover
"""Find framework packages."""
try:
from setuptools import find_namespace_packages
@@ -238,7 +241,7 @@
return [str(name)] + packages
-def main(): # pragma: no cover
+def main() -> None: # pragma: no cover
"""Setup entry point."""
version = get_validated_version()
setup(
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/833010
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I2b0fab10e2005bcad95b9a1268dd0666f4fb2683
Gerrit-Change-Number: 833010
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/833004 )
Change subject: [doc] Update ROADMAP.rst
......................................................................
[doc] Update ROADMAP.rst
Change-Id: I8ca44577a088d20d7619505cb490f768955a57ad
---
M ROADMAP.rst
1 file changed, 3 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index a409089..e06a898 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -1,12 +1,14 @@
Current release 7.7.0
^^^^^^^^^^^^^^^^^^^^^
+* OmegaWiki family was removed
+* Provide global ``-config`` option to specify the user config file name
* Run :mod:`pywikibot.scripts.login` script in parallel tasks if ``-async`` option is given (:phab:`T57899`)
* Ability to preload categories was added to :meth:`APISite.preloadpages
<pywikibot.site._generators.GeneratorsMixin.preloadpages>` (:phab:`T241689`)
* Add :class:`WikiBlame<page._toolforge.WikiBlameMixin>` support was added to get the five topmost authors
* Raise KeyError instead of AttributeError if :class:`page.FileInfo` is used as Mapping
-* L10N updates
+* i28n and L10N updates
Deprecations
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/833004
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I8ca44577a088d20d7619505cb490f768955a57ad
Gerrit-Change-Number: 833004
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/832729 )
Change subject: [tests] Improvements for script_tests.py
......................................................................
[tests] Improvements for script_tests.py
- change auto_run_script_list to a set
- change _allowed_failures to a set
- use test_pattern to create test suite identifiers
Change-Id: Id504e4986d37a80b85db288801e98250d702098a
---
M tests/script_tests.py
1 file changed, 21 insertions(+), 24 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/script_tests.py b/tests/script_tests.py
index a086191..e22d409 100755
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -79,7 +79,7 @@
}
#:
-auto_run_script_list = [
+auto_run_script_set = {
'archivebot',
'blockpageschecker',
'category_redirect',
@@ -99,7 +99,7 @@
'upload',
'watchlist',
'welcome',
-]
+}
# Expected result for no arguments
# Some of these are not pretty, but at least they are informative
@@ -144,28 +144,25 @@
# Note: Raising SkipTest during load_tests will
# cause the loader to fallback to its own
# discover() ordering of unit tests.
-
if unrunnable_script_set:
unittest_print('Skipping execution of unrunnable scripts:\n {!r}'
.format(unrunnable_script_set))
+ test_pattern = 'tests.script_tests.TestScript{}.test_{}'
+
tests = ['_login'] + [name for name in sorted(script_list)
if name != 'login'
and name not in unrunnable_script_set]
- test_list = ['tests.script_tests.TestScriptHelp.test_' + name
- for name in tests]
+ test_list = [test_pattern.format('Help', name) for name in tests]
tests = [name for name in tests if name not in failed_dep_script_set]
- test_list += ['tests.script_tests.TestScriptSimulate.test_' + name
- for name in tests]
+ test_list += [test_pattern.format('Simulate', name) for name in tests]
- tests = [name for name in tests if name not in auto_run_script_list]
- test_list += ['tests.script_tests.TestScriptGenerator.test_' + name
- for name in tests]
+ tests = [name for name in tests if name not in auto_run_script_set]
+ test_list += [test_pattern.format('Generator', name) for name in tests]
- tests = loader.loadTestsFromNames(test_list)
suite = unittest.TestSuite()
- suite.addTests(tests)
+ suite.addTests(loader.loadTestsFromNames(test_list))
return suite
@@ -178,11 +175,11 @@
def import_script(script_name: str):
"""Import script for coverage only (T305795)."""
if not ci_test_run:
- return
+ return # pragma: no cover
+
+ prefix = 'scripts.'
if script_name in framework_scripts:
- prefix = 'pywikibot.scripts.'
- else:
- prefix = 'scripts.'
+ prefix = 'pywikibot.' + prefix
import_module(prefix + script_name)
@@ -197,7 +194,7 @@
args = []
is_autorun = ('-help' not in args
- and script_name in auto_run_script_list)
+ and script_name in auto_run_script_set)
def test_script(self):
global_args_msg = \
@@ -313,7 +310,7 @@
dct[test_name] = unittest.expectedFailure(dct[test_name])
elif script_name in dct['_allowed_failures']:
dct[test_name] = unittest.skip(
- '{} is in _allowed_failures list'
+ '{} is in _allowed_failures set'
.format(script_name))(dct[test_name])
elif script_name in failed_dep_script_set \
and arguments == '-simulate':
@@ -342,7 +339,7 @@
# Here come scripts requiring and missing dependencies, that haven't been
# fixed to output -help in that case.
_expected_failures = {'version'}
- _allowed_failures = []
+ _allowed_failures = set()
_arguments = '-help'
_results = None
@@ -371,19 +368,19 @@
'unusedfiles', # not localized for default sites
}
- _allowed_failures = [
+ _allowed_failures = {
'blockpageschecker', # not localized for some test sites
'disambredir',
'misspelling', # T94681
'noreferences',
'upload', # raises custom ValueError
'watchlist', # not logged in
- ]
+ }
_arguments = '-simulate'
_results = no_args_expected_results
_skip_results = skip_on_results
- _timeout = auto_run_script_list
+ _timeout = auto_run_script_set
class TestScriptGenerator(DefaultSiteTestCase, PwbTestCase,
@@ -420,7 +417,7 @@
'transferbot',
}
- _allowed_failures = [
+ _allowed_failures = {
'basic',
'commonscat',
'commons_information',
@@ -436,7 +433,7 @@
'solve_disambiguation',
'touch',
'weblinkchecker',
- ]
+ }
_arguments = '-simulate -page:Foo -always'
_results = ("Working on 'Foo", 'Script terminated successfully')
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/832729
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Id504e4986d37a80b85db288801e98250d702098a
Gerrit-Change-Number: 832729
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/832722 )
Change subject: [tests] remove PYWIKIBOT_TEST_AUTORUN environment variable
......................................................................
[tests] remove PYWIKIBOT_TEST_AUTORUN environment variable
- remove PYWIKIBOT_TEST_AUTORUN environment variable because nosetest
is used for doctest only and no longer affects script_tests.py
- update documentation
- remove code duplication in script_tests.collector
- don't run TestScriptGenerator for scripts in auto_run_script_list
because their behaviour is equal to TestScriptSimulate
Change-Id: I0536ec8a11d2e566255d93c66772b90913ca6498
---
M .appveyor.yml
M .github/workflows/pywikibot-ci.yml
M tests/README.rst
M tests/script_tests.py
4 files changed, 8 insertions(+), 66 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
diff --git a/.appveyor.yml b/.appveyor.yml
index 7c27493..d7a1176 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -9,7 +9,6 @@
PYWIKIBOT_PASSWD_FILE: "%appdata%\\Pywikibot\\passwordfile"
PYSETUP_TEST_EXTRAS: "1"
- PYWIKIBOT_TEST_AUTORUN: "1"
PYWIKIBOT_TEST_GUI: "1"
PYWIKIBOT_TEST_RUNNING: "1"
diff --git a/.github/workflows/pywikibot-ci.yml b/.github/workflows/pywikibot-ci.yml
index b316823..ae29edc 100644
--- a/.github/workflows/pywikibot-ci.yml
+++ b/.github/workflows/pywikibot-ci.yml
@@ -11,7 +11,6 @@
branches: [ master ]
env:
- PYWIKIBOT_TEST_AUTORUN: 1
PYWIKIBOT_TEST_RUNNING: 1
PYWIKIBOT_USERNAME: Pywikibot-test
diff --git a/tests/README.rst b/tests/README.rst
index d7c2bba..e2d17e8 100644
--- a/tests/README.rst
+++ b/tests/README.rst
@@ -105,11 +105,6 @@
Environment variables
=====================
-**PYWIKIBOT_TEST_AUTORUN**
- Enable script tests running automatically without specifying a generator.
- The scripts are listed in :attr:`tests.script_tests.auto_run_script_list`.
- Currently only *deeptest* uses it.
-
**PYWIKIBOT_TEST_GUI**
Enable :mod:`tests.gui_tests`. Used for Appveyor tests. Github actions would
fail due to ``couldn't connect to display ":1.0"`` error. Set this environment
diff --git a/tests/script_tests.py b/tests/script_tests.py
index d6c0317..a086191 100755
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -139,10 +139,6 @@
}
-enable_autorun_tests = (
- os.environ.get('PYWIKIBOT_TEST_AUTORUN', '0') == '1')
-
-
def collector(loader=unittest.loader.defaultTestLoader):
"""Load the default tests."""
# Note: Raising SkipTest during load_tests will
@@ -153,43 +149,18 @@
unittest_print('Skipping execution of unrunnable scripts:\n {!r}'
.format(unrunnable_script_set))
- if not enable_autorun_tests:
- unittest_print('Skipping execution of auto-run scripts '
- '(set PYWIKIBOT_TEST_AUTORUN=1 to enable):\n {!r}'
- .format(auto_run_script_list))
-
- tests = (['test__login']
- + ['test_' + name
- for name in sorted(script_list)
- if name != 'login'
- and name not in unrunnable_script_set
- ])
-
- test_list = ['tests.script_tests.TestScriptHelp.' + name
+ tests = ['_login'] + [name for name in sorted(script_list)
+ if name != 'login'
+ and name not in unrunnable_script_set]
+ test_list = ['tests.script_tests.TestScriptHelp.test_' + name
for name in tests]
- tests = (['test__login']
- + ['test_' + name
- for name in sorted(script_list)
- if name != 'login'
- and name not in failed_dep_script_set
- and name not in unrunnable_script_set
- and (enable_autorun_tests or name not in auto_run_script_list)
- ])
-
- test_list += ['tests.script_tests.TestScriptSimulate.' + name
+ tests = [name for name in tests if name not in failed_dep_script_set]
+ test_list += ['tests.script_tests.TestScriptSimulate.test_' + name
for name in tests]
- tests = (['test__login']
- + ['test_' + name
- for name in sorted(script_list)
- if name != 'login'
- and name not in failed_dep_script_set
- and name not in unrunnable_script_set
- and (enable_autorun_tests or name not in auto_run_script_list)
- ])
-
- test_list += ['tests.script_tests.TestScriptGenerator.' + name
+ tests = [name for name in tests if name not in auto_run_script_list]
+ test_list += ['tests.script_tests.TestScriptGenerator.test_' + name
for name in tests]
tests = loader.loadTestsFromNames(test_list)
@@ -228,12 +199,6 @@
is_autorun = ('-help' not in args
and script_name in auto_run_script_list)
- def test_skip_script(self):
- raise unittest.SkipTest(
- 'Skipping execution of auto-run scripts (set '
- 'PYWIKIBOT_TEST_AUTORUN=1 to enable) "{}"'
- .format(script_name))
-
def test_script(self):
global_args_msg = \
'For global options use -help:global or run pwb'
@@ -322,8 +287,6 @@
self.assertIn(result['exit_code'], exit_codes)
sys.stdout.flush()
- if not enable_autorun_tests and is_autorun:
- return test_skip_script
return test_script
arguments = dct['_arguments']
@@ -433,46 +396,32 @@
_expected_failures = {
'login',
'add_text',
- 'archivebot',
'category',
- 'category_redirect',
'change_pagelang',
- 'checkimages',
'claimit',
- 'clean_sandbox',
'dataextend',
'data_ingestion',
'delete',
- 'delinker',
'djvutext',
'download_dump',
'harvest_template',
'interwiki',
'listpages',
- 'misspelling',
'movepages',
'pagefromfile',
- 'parser_function_count',
- 'patrol',
'protect',
'redirect',
'reflinks',
'replicate_wiki',
'revertbot',
- 'shell',
'speedy_delete',
'template',
'templatecount',
'transferbot',
- 'unusedfiles',
- 'upload',
- 'watchlist',
- 'welcome',
}
_allowed_failures = [
'basic',
- 'blockpageschecker',
'commonscat',
'commons_information',
'coordinate_import',
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/832722
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I0536ec8a11d2e566255d93c66772b90913ca6498
Gerrit-Change-Number: 832722
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/831178 )
Change subject: [IMPR] Simplify _decide_encoding
......................................................................
[IMPR] Simplify _decide_encoding
Change-Id: I67bebe73180bf01d44e282a737aab42e722b528e
---
M pywikibot/comms/http.py
1 file changed, 6 insertions(+), 12 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index c5c4b11..4948f15 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -480,25 +480,19 @@
# No charset requested, or in request headers or response headers.
# Defaults to latin1.
- if charset is None and header_encoding is None:
- return _try_decode(response.content, 'latin1')
+ if charset is None:
+ return _try_decode(response.content, header_encoding or 'latin1')
- if charset is None and header_encoding is not None:
- return _try_decode(response.content, header_encoding)
-
- if charset is not None and header_encoding is None:
+ if header_encoding is None:
return _try_decode(response.content, charset)
# Both charset and header_encoding are available.
- try:
+ header_codecs = charset_codecs = None
+ with suppress(LookupError):
header_codecs = codecs.lookup(header_encoding)
- except LookupError:
- header_codecs = None
- try:
+ with suppress(LookupError):
charset_codecs = codecs.lookup(charset)
- except LookupError:
- charset_codecs = None
if header_codecs and charset_codecs and header_codecs != charset_codecs:
pywikibot.warning(
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/831178
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I67bebe73180bf01d44e282a737aab42e722b528e
Gerrit-Change-Number: 831178
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged