jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/450460 )
Change subject: Use 'rvslots' when fetching revisions on MW 1.32+
......................................................................
Use 'rvslots' when fetching revisions on MW 1.32+
The only places that use 'rvprop' parameter directly are in
APISite.loadrevisions and APISite.preloadpages. Modify them to
add rvslots to the query if the MW version is >= 1.32.
The recieved pagedata format will also change. Adapt the api._update_revisions
method to the new format.
This is a temporary workaround to silence the API warnings. We perhaps need to
update the Revision class for other slot types in the future.
Bug: T200955
Change-Id: Ia4d655a46bf83a969b907280c7a9e24e8782b9a8
---
M pywikibot/data/api.py
M pywikibot/site.py
M tests/api_tests.py
3 files changed, 14 insertions(+), 3 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 9d35047..188bd25 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -3291,6 +3291,8 @@
"""Update page revisions."""
# TODO: T102735: Use the page content model for <1.21
for rev in revisions:
+ if 'slots' in rev and 'main' in rev['slots']: # MW 1.32+
+ rev.update(rev['slots']['main'])
revision = pywikibot.page.Revision(
revid=rev['revid'],
timestamp=pywikibot.Timestamp.fromISOformat(rev['timestamp']),
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 49db849..0adfbcc 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -3371,6 +3371,8 @@
else:
rvgen.request['titles'] = list(cache.keys())
rvgen.request['rvprop'] = rvprop
+ if self.version() >= MediaWikiVersion('1.32'):
+ rvgen.request['rvslots'] = '*'
pywikibot.output(u"Retrieving %s pages from %s."
% (len(cache), self))
@@ -4064,6 +4066,10 @@
rvargs = {'type_arg': 'info|revisions'}
rvargs['rvprop'] = ['ids', 'timestamp', 'flags', 'comment', 'user']
+ if self.version() >= MediaWikiVersion('1.32'):
+ rvargs['rvslots'] = '*'
+ # 'roles' is not implemented in Revision class yet.
+ # rvargs['rvprop'].append('roles')
if MediaWikiVersion(self.version()) >= MediaWikiVersion('1.21'):
rvargs['rvprop'].append('contentmodel')
if MediaWikiVersion(self.version()) >= MediaWikiVersion('1.19'):
diff --git a/tests/api_tests.py b/tests/api_tests.py
index 84157c7..0a04e61 100644
--- a/tests/api_tests.py
+++ b/tests/api_tests.py
@@ -783,12 +783,15 @@
links = list(self.site.pagelinks(mainpage, total=30))
titles = [l.title(with_section=False)
for l in links]
+ params = {
+ 'rvprop': 'ids|flags|timestamp|user|comment|content',
+ 'titles': '|'.join(titles)}
+ if self.site.version() >= MediaWikiVersion('1.32'):
+ params['rvslots'] = 'main'
gen = api.PropertyGenerator(
site=self.site,
prop='revisions|info|categoryinfo|langlinks|templates',
- parameters={
- 'rvprop': 'ids|flags|timestamp|user|comment|content',
- 'titles': '|'.join(titles)})
+ parameters=params)
# An APIError is raised if set_maximum_items is not called.
gen.set_maximum_items(-1) # suppress use of "rvlimit" parameter
--
To view, visit https://gerrit.wikimedia.org/r/450460
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia4d655a46bf83a969b907280c7a9e24e8782b9a8
Gerrit-Change-Number: 450460
Gerrit-PatchSet: 6
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
Mpaa has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/449025 )
Change subject: [cleanup] Remove unsupported removeImage and placeImage Page methods
......................................................................
[cleanup] Remove unsupported removeImage and placeImage Page methods
removeImage and placeImage Page methods where never part of the
rewrite/core release. A deprecation warning is shown if the one
tries to use it but the method does just nothing.
Remove this part of code after this long time (since 27.02.08),
because it seems better to raise an attribute error instead of
having a wrong behaviour for old scripts.
Bug: T106121
Change-Id: Ieb1d6a0cad06732699fff0aac01e91c358538540
---
M pywikibot/page.py
1 file changed, 0 insertions(+), 8 deletions(-)
Approvals:
jenkins-bot: Verified
Dvorapa: Looks good to me, but someone else must approve
Mpaa: Looks good to me, approved
diff --git a/pywikibot/page.py b/pywikibot/page.py
index df0de1d..b6dffa4 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -2250,14 +2250,6 @@
restrictions = self.protection()
return {k: list(restrictions[k]) for k in restrictions}
- def __getattr__(self, name):
- """Generic disabled method warnings."""
- if name in ('removeImage', 'replaceImage'):
- issue_deprecation_warning(name, None, 2, since='20080227')
- return lambda x: None
- raise AttributeError("'{0}' object has no attribute '{1}'"
- .format(self.__class__.__name__, name))
-
class Page(BasePage):
--
To view, visit https://gerrit.wikimedia.org/r/449025
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ieb1d6a0cad06732699fff0aac01e91c358538540
Gerrit-Change-Number: 449025
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/450214 )
Change subject: Rename all PYWIKIBOT2_* environment variables to PYWIKIBOT_*
......................................................................
Rename all PYWIKIBOT2_* environment variables to PYWIKIBOT_*
pywikibot.config2.py:
Normalize environment variables and issue a deprecation for the old
names. By normalizing environment variable names in config2.py
there is no need to check for old names in any other module that
imports pywikibot first.
Use the new enviroment variable names in all files.
There are only two modules that do not import pywikibot prior to checking
for PYWIKIBOT2_* variables: generate_family_file and generate_user_file.
generate_family_file.py:
Create a new function, _import_with_no_user_config, that will
import the requested module without loading user-config.py.
This function automatically sets PYWIKIBOT_NO_USER_CONFIG=2 and
restores its original value after the import is completed.
Use the new functon to import MWSite as Wiki.
generate_user_file.py:
Use the new function introduced in generate_family_file.py to
import pywikibot without user-config.py file.
PYWIKIBOT2_USER_CONFIG was only used in appveyor.yml. Rename it
without deprecation.
Bug: T184674
Change-Id: I316358e51a62d19a3a0d6e8f7a707fda7b83bff4
---
M .appveyor.yml
M HISTORY.rst
M docs/conf.py
M generate_family_file.py
M generate_user_files.py
M pwb.py
M pywikibot/config2.py
M pywikibot/site_detect.py
M scripts/version.py
M tests/README.rst
M tests/aspects.py
M tests/pwb/print_env.py
M tests/ui_tests.bat
M tests/ui_tests.py
M tox.ini
15 files changed, 78 insertions(+), 61 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.appveyor.yml b/.appveyor.yml
index c733ec3..f0d2506 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -9,8 +9,8 @@
# See: http://stackoverflow.com/a/13751649/163740
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\run_with_env.cmd"
- PYWIKIBOT2_DIR: "%appdata%\\Pywikibot"
- PYWIKIBOT2_USER_CONFIG: "%appdata%\\Pywikibot\\user-config.py"
+ PYWIKIBOT_DIR: "%appdata%\\Pywikibot"
+ PYWIKIBOT_USER_CONFIG: "%appdata%\\Pywikibot\\user-config.py"
PYSETUP_TEST_EXTRAS: "1"
@@ -93,9 +93,9 @@
- chcp 65001
- set PYTHONIOENCODING=utf8
- - "mkdir %PYWIKIBOT2_DIR%"
- - "python -Werror::UserWarning -m generate_user_files -dir:%PYWIKIBOT2_DIR% -family:wikipedia -lang:en -v -debug"
- - ps: "[IO.File]::AppendAllText($env:PYWIKIBOT2_USER_CONFIG, 'max_retries = 2; maximum_GET_length = 5000; transliteration_target = None;')"
+ - "mkdir %PYWIKIBOT_DIR%"
+ - "python -Werror::UserWarning -m generate_user_files -dir:%PYWIKIBOT_DIR% -family:wikipedia -lang:en -v -debug"
+ - ps: "[IO.File]::AppendAllText($env:PYWIKIBOT_USER_CONFIG, 'max_retries = 2; maximum_GET_length = 5000; transliteration_target = None;')"
- set PYSETUP_TEST_NO_UI=1
- "%CMD_IN_ENV% coverage run setup.py test"
diff --git a/HISTORY.rst b/HISTORY.rst
index 83d69f2..09bd15b 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -4,6 +4,7 @@
Current release
---------------
+* Drop the '2' from PYWIKIBOT2_DIR, PYWIKIBOT2_DIR_PWB, and PYWIKIBOT2_NO_USER_CONFIG environment variables. The old names are now deprecated. The other PYWIKIBOT2_* variables which were used only for testing purposes have been renamed without deprecation. (T184674)
* Bugfixes and improvements
* Localisation updates
diff --git a/docs/conf.py b/docs/conf.py
index 5c0e12f..3cf3d95 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -256,7 +256,7 @@
def pywikibot_env():
"""Allow pywikibot modules to be imported without a user-config.py."""
- os.environ['PYWIKIBOT2_NO_USER_CONFIG'] = '1'
+ os.environ['PYWIKIBOT_NO_USER_CONFIG'] = '1'
def pywikibot_script_docstring_fixups(app, what, name, obj, options, lines):
diff --git a/generate_family_file.py b/generate_family_file.py
index 7009717..0f235cd 100755
--- a/generate_family_file.py
+++ b/generate_family_file.py
@@ -15,6 +15,7 @@
import os
import sys
+from os import environ, getenv
# creating & retrieving urls
if sys.version_info[0] > 2:
from urllib.parse import urlparse
@@ -22,18 +23,6 @@
else:
from urlparse import urlparse
-# Disable user-config checks so the family can be created first,
-# and then used when generating the user-config
-_orig_no_user_config = os.environ.get('PYWIKIBOT2_NO_USER_CONFIG')
-os.environ['PYWIKIBOT2_NO_USER_CONFIG'] = '2'
-from pywikibot.site_detect import MWSite as Wiki # noqa: E402
-
-# Reset this flag in case another script is run by pwb after this script
-if not _orig_no_user_config:
- del os.environ['PYWIKIBOT2_NO_USER_CONFIG']
-else:
- os.environ['PYWIKIBOT2_NO_USER_CONFIG'] = _orig_no_user_config
-
class FamilyFileGenerator(object):
@@ -197,7 +186,25 @@
f.write(" }[code]\n")
+def _import_with_no_user_config(*import_args):
+ """Return __import__(*import_args) without loading user-config.py."""
+ orig_no_user_config = getenv('PYWIKIBOT_NO_USER_CONFIG') or getenv(
+ 'PYWIKIBOT2_NO_USER_CONFIG')
+ environ['PYWIKIBOT_NO_USER_CONFIG'] = '2'
+ result = __import__(*import_args)
+ # Reset this flag
+ if not orig_no_user_config:
+ del environ['PYWIKIBOT_NO_USER_CONFIG']
+ else:
+ environ['PYWIKIBOT_NO_USER_CONFIG'] = orig_no_user_config
+ return result
+
+
if __name__ == "__main__":
+ # Disable user-config checks so the family can be created first,
+ # and then used when generating the user-config
+ Wiki = _import_with_no_user_config(
+ 'pywikibot.site_detect').site_detect.MWSite
if len(sys.argv) != 3:
print("""
Usage: {module} <url> <short name>
diff --git a/generate_user_files.py b/generate_user_files.py
index 0dbd20c..57dda8d 100755
--- a/generate_user_files.py
+++ b/generate_user_files.py
@@ -17,18 +17,11 @@
from textwrap import fill
from warnings import warn
+from generate_family_file import _import_with_no_user_config
+
# Disable user-config usage as we are creating it here
-_orig_no_user_config = os.environ.get('PYWIKIBOT2_NO_USER_CONFIG')
-os.environ['PYWIKIBOT2_NO_USER_CONFIG'] = '2'
-import pywikibot # noqa: E402
-from pywikibot import config, __url__ # noqa: E402
-
-# Reset this flag in case another script is run by pwb after this script
-if not _orig_no_user_config:
- del os.environ['PYWIKIBOT2_NO_USER_CONFIG']
-else:
- os.environ['PYWIKIBOT2_NO_USER_CONFIG'] = _orig_no_user_config
-
+pywikibot = _import_with_no_user_config('pywikibot')
+config, __url__ = pywikibot.config2, pywikibot.__url__
base_dir = pywikibot.config2.base_dir
try:
@@ -77,7 +70,7 @@
msg = fill("""WARNING: Your user files will be created in the directory
'%(new_base)s' you have chosen. To access these files, you will either have
to use the argument "-dir:%(new_base)s" every time you run the bot, or set
-the environment variable "PYWIKIBOT2_DIR" equal to this directory name in
+the environment variable "PYWIKIBOT_DIR" equal to this directory name in
your operating system. See your operating system documentation for how to
set environment variables.""" % {'new_base': new_base}, width=76)
pywikibot.output(msg)
diff --git a/pwb.py b/pwb.py
index 5270790..371b9e0 100755
--- a/pwb.py
+++ b/pwb.py
@@ -71,7 +71,7 @@
import pywikibot
except RuntimeError:
remove_modules()
- os.environ['PYWIKIBOT2_NO_USER_CONFIG'] = '2'
+ os.environ['PYWIKIBOT_NO_USER_CONFIG'] = '2'
import pywikibot
pwb = pywikibot
@@ -169,7 +169,7 @@
_pwb_dir = os.path.split(__file__)[0]
if sys.platform == 'win32' and sys.version_info[0] < 3:
_pwb_dir = str(_pwb_dir)
- os.environ[str('PYWIKIBOT2_DIR_PWB')] = _pwb_dir
+ os.environ['PYWIKIBOT_DIR_PWB'] = _pwb_dir
import pywikibot
pwb = pywikibot
except RuntimeError:
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 7f16263..552f060 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -4,15 +4,15 @@
User preferences are loaded from a python file called user-config.py, which
may be located in directory specified by the environment variable
-PYWIKIBOT2_DIR, or the same directory as pwb.py, or in a directory within
+PYWIKIBOT_DIR, or the same directory as pwb.py, or in a directory within
the users home. See get_base_dir for more information.
If user-config.py can not be found in any of those locations, this module
-will fail to load unless the environment variable PYWIKIBOT2_NO_USER_CONFIG
-is set to a value other than '0'. i.e. PYWIKIBOT2_NO_USER_CONFIG=1 will
+will fail to load unless the environment variable PYWIKIBOT_NO_USER_CONFIG
+is set to a value other than '0'. i.e. PYWIKIBOT_NO_USER_CONFIG=1 will
allow config to load without a user-config.py. However, warnings will be
shown if user-config.py was not loaded.
-To prevent these warnings, set PYWIKIBOT2_NO_USER_CONFIG=2.
+To prevent these warnings, set PYWIKIBOT_NO_USER_CONFIG=2.
Provides two functions to register family classes which can be used in
the user-config:
@@ -49,12 +49,13 @@
from distutils.version import StrictVersion
from locale import getdefaultlocale
+from os import getenv, environ
from warnings import warn
from requests import __version__ as requests_version
from pywikibot.logging import error, output, warning
-from pywikibot.tools import PY2
+from pywikibot.tools import PY2, issue_deprecation_warning
OSWIN32 = (sys.platform == 'win32')
@@ -65,12 +66,27 @@
import _winreg as winreg
+# Normalize old PYWIKIBOT2 environment variables and issue a deprecation warn.
+for env_name in (
+ 'PYWIKIBOT2_DIR', 'PYWIKIBOT2_DIR_PWB', 'PYWIKIBOT2_NO_USER_CONFIG',
+):
+ if env_name not in environ:
+ continue
+ env_value = environ[env_name]
+ new_env_name = env_name.replace('PYWIKIBOT2_', 'PYWIKIBOT_')
+ del environ[env_name]
+ if new_env_name not in environ:
+ environ[new_env_name] = env_value
+ issue_deprecation_warning(
+ env_name + ' environment variable', new_env_name, 0, since='20180803')
+
+
# This frozen set should contain all imported modules/variables, so it must
# occur directly after the imports. At that point globals() only contains the
# names and some magic variables (like __name__)
_imports = frozenset(name for name in globals() if not name.startswith('_'))
-__no_user_config = os.environ.get('PYWIKIBOT2_NO_USER_CONFIG')
+__no_user_config = getenv('PYWIKIBOT_NO_USER_CONFIG')
if __no_user_config == '0':
__no_user_config = None
@@ -281,7 +297,7 @@
This is determined in the following order:
1. If the script was called with a -dir: argument, use the directory
provided in this argument.
- 2. If the user has a PYWIKIBOT2_DIR environment variable, use the value
+ 2. If the user has a PYWIKIBOT_DIR environment variable, use the value
of it.
3. If user-config is present in current directory, use the current
directory.
@@ -291,7 +307,7 @@
'.pywikibot' directory (Unix and similar) under the user's home
directory.
- Set PYWIKIBOT2_NO_USER_CONFIG=1 to disable loading user-config.py
+ Set PYWIKIBOT_NO_USER_CONFIG=1 to disable loading user-config.py
@param test_directory: Assume that a user config file exists in this
directory. Used to test whether placing a user config file in this
@@ -316,14 +332,14 @@
base_dir = os.path.expanduser(base_dir)
break
else:
- if ('PYWIKIBOT2_DIR' in os.environ and
- exists(os.path.abspath(os.environ['PYWIKIBOT2_DIR']))):
- base_dir = os.path.abspath(os.environ['PYWIKIBOT2_DIR'])
+ if ('PYWIKIBOT_DIR' in environ and
+ exists(os.path.abspath(environ['PYWIKIBOT_DIR']))):
+ base_dir = os.path.abspath(environ['PYWIKIBOT_DIR'])
elif exists('.'):
base_dir = os.path.abspath('.')
- elif ('PYWIKIBOT2_DIR_PWB' in os.environ and
- exists(os.path.abspath(os.environ['PYWIKIBOT2_DIR_PWB']))):
- base_dir = os.path.abspath(os.environ['PYWIKIBOT2_DIR_PWB'])
+ elif ('PYWIKIBOT_DIR_PWB' in environ and
+ exists(os.path.abspath(environ['PYWIKIBOT_DIR_PWB']))):
+ base_dir = os.path.abspath(environ['PYWIKIBOT_DIR_PWB'])
else:
base_dir_cand = []
home = os.path.expanduser("~")
diff --git a/pywikibot/site_detect.py b/pywikibot/site_detect.py
index f1a0bfc..a591448 100644
--- a/pywikibot/site_detect.py
+++ b/pywikibot/site_detect.py
@@ -173,7 +173,7 @@
self.private_wiki = ('error' in info and
info['error']['code'] == 'readapidenied')
if self.private_wiki:
- # user-config.py is not loaded because PYWIKIBOT2_NO_USER_CONFIG
+ # user-config.py is not loaded because PYWIKIBOT_NO_USER_CONFIG
# is set to '2' by generate_family_file.py.
# Prepare a temporary config for login.
username = pywikibot.input(
diff --git a/scripts/version.py b/scripts/version.py
index f01897d..8819bc3 100755
--- a/scripts/version.py
+++ b/scripts/version.py
@@ -72,9 +72,9 @@
pywikibot.output('Toolforge hostname: {0}'.format(
toolforge_env_hostname))
- check_environ('PYWIKIBOT2_DIR')
- check_environ('PYWIKIBOT2_DIR_PWB')
- check_environ('PYWIKIBOT2_NO_USER_CONFIG')
+ check_environ('PYWIKIBOT_DIR')
+ check_environ('PYWIKIBOT_DIR_PWB')
+ check_environ('PYWIKIBOT_NO_USER_CONFIG')
pywikibot.output('Config base dir: {0}'.format(pywikibot.config2.base_dir))
for family, usernames in pywikibot.config2.usernames.items():
if usernames:
diff --git a/tests/README.rst b/tests/README.rst
index c201486..41650d9 100644
--- a/tests/README.rst
+++ b/tests/README.rst
@@ -190,13 +190,13 @@
4. go to https://circleci.com/gh/<username>/pywikibot/edit#env-vars
and add the following variables:
- - PYWIKIBOT2_NO_USER_CONFIG=2
+ - PYWIKIBOT_NO_USER_CONFIG=2
- TOXENV=py27,py34
5. push changes into the forked git repository
6. watch the build at https://circleci.com/gh/<username>/pywikibot
-PYWIKIBOT2_NO_USER_CONFIG=2 is needed because 'python setup.py test' is run.
+PYWIKIBOT_NO_USER_CONFIG=2 is needed because 'python setup.py test' is run.
TOXENV=py27,py34 is a workaround because CircleCI runs 'tox',
but there is a bug in the CircleCI default 'py26' implementation.
diff --git a/tests/aspects.py b/tests/aspects.py
index 5d1e27d..9cff787 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -1495,19 +1495,19 @@
"""Prepare the environment for running the pwb.py script."""
super(PwbTestCase, self).setUp()
self.orig_pywikibot_dir = None
- if 'PYWIKIBOT2_DIR' in os.environ:
- self.orig_pywikibot_dir = os.environ['PYWIKIBOT2_DIR']
+ if 'PYWIKIBOT_DIR' in os.environ:
+ self.orig_pywikibot_dir = os.environ['PYWIKIBOT_DIR']
base_dir = pywikibot.config.base_dir
if OSWIN32 and PY2:
base_dir = str(base_dir)
- os.environ[str('PYWIKIBOT2_DIR')] = base_dir
+ os.environ[str('PYWIKIBOT_DIR')] = base_dir
def tearDown(self):
"""Restore the environment after running the pwb.py script."""
super(PwbTestCase, self).tearDown()
- del os.environ['PYWIKIBOT2_DIR']
+ del os.environ['PYWIKIBOT_DIR']
if self.orig_pywikibot_dir:
- os.environ[str('PYWIKIBOT2_DIR')] = self.orig_pywikibot_dir
+ os.environ[str('PYWIKIBOT_DIR')] = self.orig_pywikibot_dir
def _execute(self, args, data_in=None, timeout=0, error=None):
site = self.get_site()
diff --git a/tests/pwb/print_env.py b/tests/pwb/print_env.py
index b6ea59b..72ffd90 100644
--- a/tests/pwb/print_env.py
+++ b/tests/pwb/print_env.py
@@ -23,7 +23,7 @@
if k == 'USER_PASSWORD':
continue
# This only appears in subprocesses
- if k in ['PYWIKIBOT2_DIR_PWB']:
+ if k == 'PYWIKIBOT_DIR_PWB':
continue
print("%r: %r" % (k, v))
diff --git a/tests/ui_tests.bat b/tests/ui_tests.bat
index c497d6e..68da2b6 100644
--- a/tests/ui_tests.bat
+++ b/tests/ui_tests.bat
@@ -1,4 +1,4 @@
@echo off
set PYTHONPATH=%~dp0..;%~dp0../externals
-set PYWIKIBOT2_DIR=%~dp0..
+set PYWIKIBOT_DIR=%~dp0..
"%~dp0ui_tests.py"
diff --git a/tests/ui_tests.py b/tests/ui_tests.py
index 84d93fe..9576edc 100644
--- a/tests/ui_tests.py
+++ b/tests/ui_tests.py
@@ -8,7 +8,7 @@
# NOTE FOR RUNNING WINDOWS UI TESTS
#
# Windows UI tests have to be run using the tests\ui_tests.bat helper script.
-# This will set PYTHONPATH and PYWIKIBOT2_DIR, and then run the tests. Do not
+# This will set PYTHONPATH and PYWIKIBOT_DIR, and then run the tests. Do not
# touch mouse or keyboard while the tests are running, as this might disturb the
# interaction tests.
#
diff --git a/tox.ini b/tox.ini
index 84bbe40..f6064dc 100644
--- a/tox.ini
+++ b/tox.ini
@@ -16,7 +16,7 @@
[testenv]
setenv =
VIRTUAL_ENV={envdir}
- PYWIKIBOT2_NO_USER_CONFIG=2
+ PYWIKIBOT_NO_USER_CONFIG=2
usedevelop = True
commands = python setup.py test
--
To view, visit https://gerrit.wikimedia.org/r/450214
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I316358e51a62d19a3a0d6e8f7a707fda7b83bff4
Gerrit-Change-Number: 450214
Gerrit-PatchSet: 7
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/449931 )
Change subject: Rename PYWIKIBOT2_TEST_* environment variables to PYWIKIBOT_TEST_*
......................................................................
Rename PYWIKIBOT2_TEST_* environment variables to PYWIKIBOT_TEST_*
Since these variable are only used by developers for testing purposes
I don't think a deprecation period is required.
Also rename PYWIKIBOT2_USERNAME to PYWIKIBOT_USERNAME. It is only
used in .travis.yml file.
Bug: T184674
Change-Id: I93e3d6c9f228bab9d0390684d5348eea0f7726ba
---
M .travis.yml
M tests/README.rst
M tests/aspects.py
M tests/script_tests.py
M tests/tk_tests.py
5 files changed, 31 insertions(+), 31 deletions(-)
Approvals:
Zhuyifei1999: Looks good to me, but someone else must approve
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.travis.yml b/.travis.yml
index 96f8a27..479b58b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -44,7 +44,7 @@
- chmod 700 ~/.python-eggs
- if [[ "$GITHUB_USER" != "wikimedia" ]]; then
- export PYWIKIBOT2_TEST_WRITE_FAIL=1 ;
+ export PYWIKIBOT_TEST_WRITE_FAIL=1 ;
fi
before_script:
@@ -67,21 +67,21 @@
python -m generate_family_file 'http://'$LANGUAGE'.wikisource.beta.wmflabs.org/' 'wsbeta' 'y' ;
fi
- - python -W error::UserWarning -m generate_user_files -dir:~/.pywikibot/ -family:$FAMILY -lang:$LANGUAGE -v -user:"$PYWIKIBOT2_USERNAME"
+ - python -W error::UserWarning -m generate_user_files -dir:~/.pywikibot/ -family:$FAMILY -lang:$LANGUAGE -v -user:"$PYWIKIBOT_USERNAME"
- - if [[ -n "$USER_PASSWORD" && -n "$PYWIKIBOT2_USERNAME" ]]; then
- printf "usernames['wikipedia']['en'] = '%q'\n" "$PYWIKIBOT2_USERNAME" >> ~/.pywikibot/user-config.py ;
- printf "usernames['wikipedia']['test'] = '%q'\n" "$PYWIKIBOT2_USERNAME" >> ~/.pywikibot/user-config.py ;
- printf "usernames['wikidata']['test'] = '%q'\n" "$PYWIKIBOT2_USERNAME" >> ~/.pywikibot/user-config.py ;
- printf "usernames['commons']['commons'] = '%q'\n" "$PYWIKIBOT2_USERNAME" >> ~/.pywikibot/user-config.py ;
- printf "('%q', '%q')\n" "$PYWIKIBOT2_USERNAME" "$USER_PASSWORD" > ~/.pywikibot/passwordfile ;
+ - if [[ -n "$USER_PASSWORD" && -n "$PYWIKIBOT_USERNAME" ]]; then
+ printf "usernames['wikipedia']['en'] = '%q'\n" "$PYWIKIBOT_USERNAME" >> ~/.pywikibot/user-config.py ;
+ printf "usernames['wikipedia']['test'] = '%q'\n" "$PYWIKIBOT_USERNAME" >> ~/.pywikibot/user-config.py ;
+ printf "usernames['wikidata']['test'] = '%q'\n" "$PYWIKIBOT_USERNAME" >> ~/.pywikibot/user-config.py ;
+ printf "usernames['commons']['commons'] = '%q'\n" "$PYWIKIBOT_USERNAME" >> ~/.pywikibot/user-config.py ;
+ printf "('%q', '%q')\n" "$PYWIKIBOT_USERNAME" "$USER_PASSWORD" > ~/.pywikibot/passwordfile ;
echo "import os" >> ~/.pywikibot/user-config.py ;
echo "password_file = os.path.expanduser('~/.pywikibot/passwordfile')" >> ~/.pywikibot/user-config.py ;
fi
- if [[ -n "$OAUTH_DOMAIN" ]]; then
- if [[ -n "$OAUTH_PYWIKIBOT2_USERNAME" ]]; then
- printf "usernames['${FAMILY}']['${LANGUAGE}'] = '%q'\n" "$OAUTH_PYWIKIBOT2_USERNAME" >> ~/.pywikibot/user-config.py ;
+ if [[ -n "$OAUTH_PYWIKIBOT_USERNAME" ]]; then
+ printf "usernames['${FAMILY}']['${LANGUAGE}'] = '%q'\n" "$OAUTH_PYWIKIBOT_USERNAME" >> ~/.pywikibot/user-config.py ;
fi ;
oauth_token_var="OAUTH_TOKENS_${FAMILY^^}_${LANGUAGE^^}" ;
if [[ -n "${!oauth_token_var}" ]]; then
@@ -124,13 +124,13 @@
- TEST_TIMEOUT=300
matrix:
- - LANGUAGE=en FAMILY=wikipedia PYWIKIBOT2_TEST_PROD_ONLY=1
- - LANGUAGE=zh FAMILY=wikisource PYSETUP_TEST_EXTRAS=1 PYWIKIBOT2_TEST_PROD_ONLY=1 PYWIKIBOT2_TEST_NO_RC=1
+ - LANGUAGE=en FAMILY=wikipedia PYWIKIBOT_TEST_PROD_ONLY=1
+ - LANGUAGE=zh FAMILY=wikisource PYSETUP_TEST_EXTRAS=1 PYWIKIBOT_TEST_PROD_ONLY=1 PYWIKIBOT_TEST_NO_RC=1
matrix:
include:
- python: '2.7_with_system_site_packages'
- env: LANGUAGE=nb FAMILY=wikipedia DIST=trusty PYSETUP_TEST_EXTRAS=1 PYWIKIBOT2_TEST_NO_RC=1
+ env: LANGUAGE=nb FAMILY=wikipedia DIST=trusty PYSETUP_TEST_EXTRAS=1 PYWIKIBOT_TEST_NO_RC=1
dist: trusty
sudo: required
addons:
@@ -147,7 +147,7 @@
- python: '3.4'
env: LANGUAGE=en FAMILY=wsbeta SITE_ONLY=1
- python: '2.7'
- env: LANGUAGE=wikia FAMILY=wikia PYWIKIBOT2_TEST_NO_RC=1
+ env: LANGUAGE=wikia FAMILY=wikia PYWIKIBOT_TEST_NO_RC=1
- python: '3.5'
env: LANGUAGE=en FAMILY=musicbrainz SITE_ONLY=1
- python: '3.4'
@@ -155,7 +155,7 @@
- python: '3.4'
env: LANGUAGE=test FAMILY=wikidata SITE_ONLY=1
- python: '3.4'
- env: LANGUAGE=ar FAMILY=wiktionary PYWIKIBOT2_TEST_NO_RC=1
+ env: LANGUAGE=ar FAMILY=wiktionary PYWIKIBOT_TEST_NO_RC=1
- python: '3.6'
env: LANGUAGE=wikidata FAMILY=wikidata SITE_ONLY=1
diff --git a/tests/README.rst b/tests/README.rst
index 4699d7b..c201486 100644
--- a/tests/README.rst
+++ b/tests/README.rst
@@ -142,7 +142,7 @@
a username and password to travis:
1. Go to https://travis-ci.org/<username>/pywikibot/settings
-2. Add a new variable named PYWIKIBOT2_USERNAME and a value of a valid
+2. Add a new variable named PYWIKIBOT_USERNAME and a value of a valid
Wikimedia SUL username
3. Add another variable named USER_PASSWORD, with the private password for
the Wikimedia SUL username used in step 2. Check that this
@@ -213,7 +213,7 @@
These 'edit failure' tests are disabled by default. On Travis they are enabled
by default on builds by any other github account except 'wikimedia'.
-To disable 'edit failure' tests, set PYWIKIBOT2_TEST_WRITE_FAIL=0
+To disable 'edit failure' tests, set PYWIKIBOT_TEST_WRITE_FAIL=0
There are also several other 'write' tests which also attempt to perform
write operations successfully. These **will** write to the wikis, and they
@@ -223,7 +223,7 @@
run on travis or appveyor as they require interaction using a terminal. Also
enabling them won't enable 'edit failure' tests.
-To enable 'write' tests, set PYWIKIBOT2_TEST_WRITE=1
+To enable 'write' tests, set PYWIKIBOT_TEST_WRITE=1
Enabling only 'edit failure' tests or 'write' tests won't enable the other tests
automatically.
diff --git a/tests/aspects.py b/tests/aspects.py
index fa21592..5d1e27d 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -581,10 +581,10 @@
Prevent test classes from writing to the site by default.
If class attribute 'write' is -1, the test class is skipped unless
- environment variable PYWIKIBOT2_TEST_WRITE_FAIL is set to 1.
+ environment variable PYWIKIBOT_TEST_WRITE_FAIL is set to 1.
Otherwise the test class is skipped unless environment variable
- PYWIKIBOT2_TEST_WRITE is set to 1.
+ PYWIKIBOT_TEST_WRITE is set to 1.
"""
if issubclass(cls, ForceCacheMixin):
raise Exception(
@@ -597,9 +597,9 @@
site = cls.get_site()
if cls.write == -1:
- env_var = 'PYWIKIBOT2_TEST_WRITE_FAIL'
+ env_var = 'PYWIKIBOT_TEST_WRITE_FAIL'
else:
- env_var = 'PYWIKIBOT2_TEST_WRITE'
+ env_var = 'PYWIKIBOT_TEST_WRITE'
if os.environ.get(env_var, '0') != '1':
raise unittest.SkipTest(
@@ -1014,9 +1014,9 @@
for data in cls.sites.values():
if ('code' in data and data['code'] in ('test', 'mediawiki') and
- 'PYWIKIBOT2_TEST_PROD_ONLY' in os.environ and not dry):
+ 'PYWIKIBOT_TEST_PROD_ONLY' in os.environ and not dry):
raise unittest.SkipTest(
- 'Site code "%s" and PYWIKIBOT2_TEST_PROD_ONLY is set.'
+ 'Site code "%s" and PYWIKIBOT_TEST_PROD_ONLY is set.'
% data['code'])
if 'site' not in data and 'code' in data and 'family' in data:
@@ -1530,7 +1530,7 @@
@classmethod
def setUpClass(cls):
"""Set up test class."""
- if os.environ.get('PYWIKIBOT2_TEST_NO_RC', '0') == '1':
+ if os.environ.get('PYWIKIBOT_TEST_NO_RC', '0') == '1':
raise unittest.SkipTest('RecentChanges tests disabled.')
super(RecentChangesTestCase, cls).setUpClass()
diff --git a/tests/script_tests.py b/tests/script_tests.py
index 22d1593..dbbdc98 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -166,7 +166,7 @@
enable_autorun_tests = (
- os.environ.get('PYWIKIBOT2_TEST_AUTORUN', '0') == '1')
+ os.environ.get('PYWIKIBOT_TEST_AUTORUN', '0') == '1')
def collector(loader=unittest.loader.defaultTestLoader):
@@ -181,7 +181,7 @@
if not enable_autorun_tests:
unittest_print('Skipping execution of auto-run scripts '
- '(set PYWIKIBOT2_TEST_AUTORUN=1 to enable):\n %r'
+ '(set PYWIKIBOT_TEST_AUTORUN=1 to enable):\n %r'
% auto_run_script_list)
tests = (['test__login'] +
@@ -231,7 +231,7 @@
def test_skip_script(self):
raise unittest.SkipTest(
'Skipping execution of auto-run scripts (set '
- 'PYWIKIBOT2_TEST_AUTORUN=1 to enable) "{0}"'
+ 'PYWIKIBOT_TEST_AUTORUN=1 to enable) "{0}"'
.format(script_name))
def testScript(self):
diff --git a/tests/tk_tests.py b/tests/tk_tests.py
index 60b5cb6..be2ad20 100644
--- a/tests/tk_tests.py
+++ b/tests/tk_tests.py
@@ -14,7 +14,7 @@
from tests.aspects import unittest, TestCase, DefaultSiteTestCase
-if os.environ.get('PYWIKIBOT2_TEST_GUI', '0') == '1':
+if os.environ.get('PYWIKIBOT_TEST_GUI', '0') == '1':
if not PY2:
import tkinter as Tkinter
else:
@@ -31,7 +31,7 @@
@classmethod
def setUpClass(cls):
"""Set up test class."""
- if os.environ.get('PYWIKIBOT2_TEST_GUI', '0') != '1':
+ if os.environ.get('PYWIKIBOT_TEST_GUI', '0') != '1':
raise unittest.SkipTest('Tkdialog tests are disabled on Travis-CI')
super(TestTkdialog, cls).setUpClass()
@@ -53,7 +53,7 @@
@classmethod
def setUpClass(cls):
"""Set up test class."""
- if os.environ.get('PYWIKIBOT2_TEST_GUI', '0') != '1':
+ if os.environ.get('PYWIKIBOT_TEST_GUI', '0') != '1':
raise unittest.SkipTest('Tkinter tests are disabled on Travis-CI')
super(TestTkinter, cls).setUpClass()
--
To view, visit https://gerrit.wikimedia.org/r/449931
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I93e3d6c9f228bab9d0390684d5348eea0f7726ba
Gerrit-Change-Number: 449931
Gerrit-PatchSet: 3
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)