jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[tests] use pytests for jenkins instead of nose

Bug: T244087
Bug: T195825
Change-Id: I8f8fe1780d080b23e28eb09f3e5ba6beb2a0d010
---
M dev-requirements.txt
M tests/README.rst
M tests/aspects.py
M tests/script_tests.py
M tox.ini
5 files changed, 13 insertions(+), 43 deletions(-)

diff --git a/dev-requirements.txt b/dev-requirements.txt
index c02f809..974c2dd 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -12,8 +12,6 @@
werkzeug>=0.15.5
pytest-httpbin

-nose
-
pep257>=0.6
pyflakes>=2.1.0
flake8>=3.7.5
diff --git a/tests/README.rst b/tests/README.rst
index 7e4da13..7d47c91 100644
--- a/tests/README.rst
+++ b/tests/README.rst
@@ -3,8 +3,7 @@
===============

The Pywikibot tests are based on the `unittest framework
-<https://docs.python.org/3/library/unittest.html>`_,
-and are compatible with `nose <https://nose.readthedocs.org/>`_.
+<https://docs.python.org/3/library/unittest.html>`_.

The tests package provides a function load_tests that supports the
`load tests protocol
@@ -28,10 +27,6 @@

::

- python setup.py nosetests --tests tests
-
-::
-
pip install pytest-runner
python setup.py pytest

@@ -42,13 +37,6 @@

python -m unittest discover -v -p "*_tests.py"

-nose
-~~~~
-
-::
-
- nosetests -v
-
pytest
~~~~~~

@@ -66,7 +54,7 @@
Specific tests
--------------

-Individual test components can be run using unittest, nosetests, or pwb.
+Individual test components can be run using unittest, pytest or pwb.
With -lang and -family or -site options pwb can be used to specify a site.


@@ -78,14 +66,6 @@
python -m unittest -v tests.api_tests tests.site_tests
python -m unittest -v tests.api_tests.TestParamInfo.test_init

-nose
-~~~~
-
-::
-
- nosetests -v tests.api_tests tests.site_tests
- python -m nose -v tests.api_tests:TestParamInfo.test_init
-
pytest
~~~~~~

diff --git a/tests/aspects.py b/tests/aspects.py
index b270026..f167e64 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -294,14 +294,6 @@
return obj
skip_decorator = unittest.skip('{0} not installed'.format(
', '.join(missing)))
- if (inspect.isclass(obj) and issubclass(obj, TestCaseBase)
- and 'nose' in sys.modules.keys()):
- # There is a known bug in nosetests which causes setUpClass()
- # to be called even if the unittest class is skipped.
- # Here, we decorate setUpClass() as a patch to skip it
- # because of the missing modules too.
- # Upstream report: https://github.com/nose-devs/nose/issues/946
- obj.setUpClass = classmethod(skip_decorator(lambda cls: None))
return skip_decorator(obj)

return test_requirement
@@ -315,7 +307,7 @@

Never set a class or instance variable called 'site'
As it will prevent tests from executing when invoked as:
- $ nosetests -a '!site' -v
+ $ pytest -a 'not site'
"""

def setUp(self):
@@ -371,7 +363,7 @@

Never set a class or instance variable called 'site'
As it will prevent tests from executing when invoked as:
- $ nosetests -a '!site' -v
+ $ pytest -a 'not site'
"""

def setUp(self):
@@ -730,7 +722,7 @@
.format(name))

# If the 'site' attribute is a false value,
- # remove it so it matches !site in nose.
+ # remove it so it matches 'not site' in pytest.
if 'site' in dct:
del dct['site']

@@ -741,7 +733,7 @@
.format(name))

# If the 'net' attribute is a false value,
- # remove it so it matches !net in nose.
+ # remove it so it matches 'not net' in pytest.
if not dct['net']:
del dct['net']

diff --git a/tests/script_tests.py b/tests/script_tests.py
index 774b605..c9ee80f 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -325,7 +325,7 @@
'{} has dependencies; skipping'
.format(script_name))(dct[test_name])

- # Disable test by default in nosetests
+ # Disable test by default in pytest
if script_name in unrunnable_script_set:
# flag them as an expectedFailure due to py.test (T135594)
dct[test_name] = unittest.expectedFailure(dct[test_name])
@@ -357,7 +357,7 @@

"""Test cases for scripts.

- This class sets the nose 'user' attribute on every test, thereby ensuring
+ This class sets the'user' attribute on every test, thereby ensuring
that the test runner has a username for the default site, and so that
Site.login() is called in the test runner, which means that the scripts
run in pwb can automatically login using the saved cookies.
diff --git a/tox.ini b/tox.ini
index f3afe7b..c074e4b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -33,16 +33,16 @@
test: python -m unittest discover -vv -p "*_tests.py"

fasttest: python -W error::UserWarning -m generate_user_files -family:wikipedia -lang:test -v
- fasttest: nosetests --version
- fasttest: nosetests --with-detecthttp --exclude-dir=/src/tests/archive -v -a '!net' tests
+ fasttest: pytest --version
+ fasttest: pytest -a 'not net'
deps =
flake8: .[flake8]

- fasttest: nose
+ fasttest: pytest >= 5.3
+ fasttest: pytest-attrib>=0.1.3
+ fasttest: pytest-subtests >= 0.3.2
fasttest: mock
fasttest: .[scripts]
- fasttest: nose-detecthttp>=0.1.3
- fasttest: nose-exclude

fasttest-py35: mwparserfromhell
fasttest-py35: beautifulsoup4

To view, visit change 666642. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I8f8fe1780d080b23e28eb09f3e5ba6beb2a0d010
Gerrit-Change-Number: 666642
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged