jenkins-bot has submitted this change and it was merged.
Change subject: Use py.test for some Travis jobs with 300s timeout
......................................................................
Use py.test for some Travis jobs with 300s timeout
Use pytest-runner to run tests using py.test
and pytest-timeout to kill jobs which take too long.
Use py.text except for SITE_ONLY=1 or PYSETUP_TEST_EXTRAS=1
Bug: T115313
Change-Id: Iae8a77918a3a4ce5a1dba731be6d47716b1c8d02
---
M .travis.yml
M dev-requirements.txt
M tests/README.rst
M tests/script_tests.py
M tests/weblib_tests.py
M tox.ini
6 files changed, 48 insertions(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.travis.yml b/.travis.yml
index 90cbacb..15d08b9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -30,7 +30,12 @@
# Instead install requests in the before_script step below.
- if [[ "$PYSETUP_TEST_EXTRAS" != '1' ]]; then rm requirements.txt ;
fi
- - if [[ "$SITE_ONLY" == '1' ]]; then export USE_NOSE=1; fi
+ - if [[ "$SITE_ONLY" == '1' ]]; then
+ export USE_NOSE=1 ;
+ elif [[ "$PYSETUP_TEST_EXTRAS" != '1' ]]; then
+ export USE_PYTEST=1 ;
+ fi
+
- export GITHUB_USER=`echo $TRAVIS_REPO_SLUG | cut -d '/' -f 1`
- mkdir ~/.python-eggs
- chmod 700 ~/.python-eggs
@@ -95,6 +100,9 @@
else
python setup.py nosetests --tests tests --verbosity=2 --with-coverage
--cover-package=. ;
fi ;
+ elif [[ "$USE_PYTEST" == "1" ]]; then
+ pip install --upgrade pytest-runner pytest-cov pytest-timeout
"pytest>=2.8.0" ;
+ python setup.py pytest --addopts="-vvv -s --timeout=300 --cov=." ;
else
coverage run setup.py test ;
fi
diff --git a/dev-requirements.txt b/dev-requirements.txt
index d990436..65c3ee8 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -2,6 +2,14 @@
#
unittest2==0.8.0 ; python_full_version < '2.7.3'
+pytest
+# These are used by only some Travis builds
+# pytest-timeout needs >=2.8.0
+# pytest>=2.8.0
+# pytest-timeout
+# pytest-runner
+# pytest-cov
+
six
nose
diff --git a/tests/README.rst b/tests/README.rst
index 9c80c36..fff848f 100644
--- a/tests/README.rst
+++ b/tests/README.rst
@@ -34,6 +34,10 @@
python setup.py nosetests --tests tests
+::
+
+ pip install pytest-runner
+ python setup.py pytest
Module unittest
~~~~~~~~~~~~~~~
@@ -48,6 +52,13 @@
::
nosetests -v
+
+pytest
+~~~~~~
+
+::
+
+ py.test
tox
~~~
@@ -67,6 +78,7 @@
::
python -m unittest -v tests.api_tests tests.site_tests
+ python -m unittest -v tests.api_tests.TestParamInfo.test_init
nose
~~~~
@@ -74,6 +86,15 @@
::
nosetests -v tests.api_tests tests.site_tests
+ python -m unittest -v tests.api_tests:TestParamInfo.test_init
+
+pytest
+~~~~~~
+
+::
+
+ py.test -s -v tests/api_tests.py tests/site_tests.py
+ py.test -s -v tests/api_tests.py::TestParamInfo::test_init
pwb
~~~
@@ -82,6 +103,7 @@
python pwb.py tests/api_tests.py -v
python pwb.py tests/site_tests.py -v
+ python pwb.py tests/api_tests.py -v TestParamInfo.test_init
env
~~~
diff --git a/tests/script_tests.py b/tests/script_tests.py
index 4fdd9ec..5837e98 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -363,6 +363,8 @@
# Disable test by default in nosetests
if script_name in unrunnable_script_list:
+ # flag them as an expectedFailure due to py.test (T135594)
+ dct[test_name] = unittest.expectedFailure(dct[test_name])
dct[test_name].__test__ = False
return super(TestScriptMeta, cls).__new__(cls, name, bases, dct)
diff --git a/tests/weblib_tests.py b/tests/weblib_tests.py
index 13c5a13..3ef7c70 100644
--- a/tests/weblib_tests.py
+++ b/tests/weblib_tests.py
@@ -77,6 +77,7 @@
self.assertOneDeprecation()
return archivedversion
+ @unittest.expectedFailure # See T110640
def testWebCiteOlder(self):
"""Test WebCite for
https://google.com as of January
2013."""
archivedversion = self._get_archive_url('https://google.com',
'20130101')
diff --git a/tox.ini b/tox.ini
index 5d34c3a..040e501 100644
--- a/tox.ini
+++ b/tox.ini
@@ -152,3 +152,9 @@
[pep257]
# see explanations above
ignore = D105,D211
+
+[pytest]
+python_files=tests/*.py
+# disable recursing into tests/pwb, as that prints the environment,
+# exposing any secure variables in Travis.
+norecursedirs=.git .svn .tox pwb
--
To view, visit
https://gerrit.wikimedia.org/r/289385
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iae8a77918a3a4ce5a1dba731be6d47716b1c8d02
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>