jenkins-bot has submitted this change and it was merged.
Change subject: Automatic tox testing ......................................................................
Automatic tox testing
- Do not run flake8-docstrings by default, as it does not pass - unittest2 is needed for py26 env - use PYWIKIBOT2_NO_USER_CONFIG=2 to prevent pwb warnings when user-config.py is not found. - Document testing using tox and CircleCI, including workaround for CircleCI bug preventing use of py26.
Change-Id: I07694854f1f44a100e0222b464dd4a007acda01d --- M generate_user_files.py M pywikibot/config2.py M tests/README.rst M tox.ini 4 files changed, 54 insertions(+), 16 deletions(-)
Approvals: XZise: Looks good to me, approved jenkins-bot: Verified
diff --git a/generate_user_files.py b/generate_user_files.py index f29860a..5176b97 100755 --- a/generate_user_files.py +++ b/generate_user_files.py @@ -343,25 +343,27 @@ """ global base_dir
- default_args = (config.family, config.mylang, None) + # set the config family and mylang values to an invalid state so that + # the script can detect that the command line arguments -family & -lang + # were used and and handle_args has updated these config values, + # and 'force' mode can be activated below. + (config.family, config.mylang) = ('wikipedia', None)
local_args = pywikibot.handle_args(args) if local_args: pywikibot.output('Unknown arguments: %s' % ' '.join(local_args)) return False
- username = config.usernames[config.family].get(config.mylang) - args = (config.family, config.mylang, username) - - if args != default_args: + if config.mylang is not None: force = True pywikibot.output(u'Automatically generating user-config.py') else: force = False + # Force default site of en.wikipedia + (config.family, config.mylang) = ('wikipedia', 'en')
- # Force default - if config.family == 'wikipedia' and config.mylang == 'language': - args = ('wikipedia', 'en', username) + username = config.usernames[config.family].get(config.mylang) + args = (config.family, config.mylang, username)
while not force or config.verbose_output: pywikibot.output(u'\nYour default user directory is "%s"' % base_dir) diff --git a/pywikibot/config2.py b/pywikibot/config2.py index b8898fd..774a818 100644 --- a/pywikibot/config2.py +++ b/pywikibot/config2.py @@ -1056,9 +1056,10 @@
# Fix up default site -if family == 'wikipedia' and mylang == 'language' and _no_user_config != '2': - print("WARNING: family and mylang are not set.\n" - "Defaulting to family='test' and mylang='test'.") +if family == 'wikipedia' and mylang == 'language': + if _no_user_config != '2': + print("WARNING: family and mylang are not set.\n" + "Defaulting to family='test' and mylang='test'.") family = mylang = 'test'
# SECURITY WARNINGS diff --git a/tests/README.rst b/tests/README.rst index ed96b88..9c80c36 100644 --- a/tests/README.rst +++ b/tests/README.rst @@ -21,7 +21,7 @@ All tests ---------
-The entire suite of tests may be run in three ways from the root directory: +The entire suite of tests may be run in the following ways from the root directory:
setup.py ~~~~~~~~ @@ -48,6 +48,13 @@ ::
nosetests -v + +tox +~~~ + +:: + + tox
Specific tests -------------- @@ -144,11 +151,34 @@ 3. create a project in ci.appveyor.com 4. go to https://ci.appveyor.com/project/<username>/pywikibot-core/settings and enter the custom configuration .yml filename: .appveyor.yml -4. push changes into the forked git repository -5. watch the build at https://ci.appveyor.com/<username>/pywikibot-core/history +5. push changes into the forked git repository +6. watch the build at https://ci.appveyor.com/<username>/pywikibot-core/history
The 'user' tests are not yet enabled on appveyor builds.
+CircleCI +======== + +After changes are published into a github repository, tests may be run on +CircleCI Ubuntu servers. + +1. create a github and circleci account +2. fork the main github repository +3. create a project in circleci.com +4. go to https://circleci.com/gh/<username>/pywikibot-core/edit#env-vars + and add the following variables: + PYWIKIBOT2_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-core + +PYWIKIBOT2_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. + +This approach does not include 'user' tests. + Environment variables =====================
diff --git a/tox.ini b/tox.ini index 6a052c3..e2acf3f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,17 +1,22 @@ [tox] minversion = 1.6 skipsdist = True -envlist = flake8,flake83,flake8-docstrings,py26,py27,py34 +envlist = flake8,flake8-py3,flake8-docstrings-mandatory,py26,py27,py34
[params] nose_skip = --ignore-files=(gui.py|botirc.py|rcstream.py)
[testenv] -setenv = VIRTUAL_ENV={envdir} +setenv = + VIRTUAL_ENV={envdir} + PYWIKIBOT2_NO_USER_CONFIG=2 usedevelop = True commands = python setup.py test install_command = pip install --process-dependency-links --pre {opts} {packages}
+[testenv:py26] +deps = unittest2 + [testenv:flake8] commands = flake8 --ignore=D102,D103,E122,E127,E241,E402,E731 {posargs} basepython = python2.7
pywikibot-commits@lists.wikimedia.org