Switch to pytest
nose has not seen active development for many years now. With py310, we can no longer use it due to import errors. Also update lower contraints Closes-Bug: #1993531 Change-Id: I215ba0d4654c9c637c3b97953d8659ac80892db8
This commit is contained in:
parent
745dfec35e
commit
ef155bd74a
@ -3,7 +3,7 @@
|
||||
SRC_DIR=$(dirname $(realpath "$0"))
|
||||
|
||||
cd ${SRC_DIR}/test/probe
|
||||
nosetests --exe $@
|
||||
pytest $@
|
||||
rvalue=$?
|
||||
cd -
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
TOP_DIR=$(dirname $(realpath "$0"))
|
||||
|
||||
cd $TOP_DIR/test/unit
|
||||
nosetests --exe --with-coverage --cover-package swift --cover-erase --cover-branches --cover-html --cover-html-dir="$TOP_DIR"/cover $@
|
||||
pytest --cov-report=html:"$TOP_DIR"/cover $@
|
||||
rvalue=$?
|
||||
rm -f .coverage
|
||||
cd -
|
||||
|
15
.zuul.yaml
15
.zuul.yaml
@ -25,9 +25,6 @@
|
||||
vars:
|
||||
tox_envlist: py27
|
||||
python_version: 2.7
|
||||
tox_environment:
|
||||
NOSE_COVER_HTML: 1
|
||||
NOSE_COVER_HTML_DIR: '{toxinidir}/cover'
|
||||
post-run: tools/playbooks/common/cover-post.yaml
|
||||
|
||||
- job:
|
||||
@ -52,9 +49,6 @@
|
||||
tox_envlist: py36
|
||||
bindep_profile: test py36
|
||||
python_version: 3.6
|
||||
tox_environment:
|
||||
NOSE_COVER_HTML: 1
|
||||
NOSE_COVER_HTML_DIR: '{toxinidir}/cover'
|
||||
post-run: tools/playbooks/common/cover-post.yaml
|
||||
|
||||
- job:
|
||||
@ -76,9 +70,6 @@
|
||||
tox_envlist: py37
|
||||
bindep_profile: test py37
|
||||
python_version: 3.7
|
||||
tox_environment:
|
||||
NOSE_COVER_HTML: 1
|
||||
NOSE_COVER_HTML_DIR: '{toxinidir}/cover'
|
||||
post-run: tools/playbooks/common/cover-post.yaml
|
||||
|
||||
- job:
|
||||
@ -95,9 +86,6 @@
|
||||
tox_envlist: py38
|
||||
bindep_profile: test py38
|
||||
python_version: 3.8
|
||||
tox_environment:
|
||||
NOSE_COVER_HTML: 1
|
||||
NOSE_COVER_HTML_DIR: '{toxinidir}/cover'
|
||||
post-run: tools/playbooks/common/cover-post.yaml
|
||||
|
||||
- job:
|
||||
@ -130,9 +118,6 @@
|
||||
tox_envlist: py39
|
||||
bindep_profile: test py39
|
||||
python_version: 3.9
|
||||
tox_environment:
|
||||
NOSE_COVER_HTML: 1
|
||||
NOSE_COVER_HTML_DIR: '{toxinidir}/cover'
|
||||
post-run: tools/playbooks/common/cover-post.yaml
|
||||
|
||||
- job:
|
||||
|
@ -145,11 +145,11 @@ Running the tests above against Swift in your development environment
|
||||
to be both tested and documented and all tests should pass.
|
||||
|
||||
If you want to run just a subset of the tests while you are developing,
|
||||
you can use nosetests:
|
||||
you can use pytest:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
cd test/unit/common/middleware/ && nosetests test_healthcheck.py
|
||||
cd test/unit/common/middleware/ && pytest test_healthcheck.py
|
||||
|
||||
To check which parts of your code are being exercised by a test, you can
|
||||
run tox and then point your browser to swift/cover/index.html:
|
||||
|
@ -197,7 +197,7 @@ edited to provide AWS key IDs and secrets. Alternatively, an AWS CLI style
|
||||
credentials file can be loaded by setting the ``SWIFT_TEST_AWS_CONFIG_FILE``
|
||||
environment variable, e.g.::
|
||||
|
||||
SWIFT_TEST_AWS_CONFIG_FILE=~/.aws/credentials nosetests ./test/s3api
|
||||
SWIFT_TEST_AWS_CONFIG_FILE=~/.aws/credentials pytest ./test/s3api
|
||||
|
||||
.. note::
|
||||
When using ``SWIFT_TEST_AWS_CONFIG_FILE``, the region defaults to
|
||||
|
@ -11,7 +11,7 @@ cffi==1.11.5
|
||||
chardet==3.0.4
|
||||
cliff==2.11.0
|
||||
cmd2==0.8.1
|
||||
coverage==3.6
|
||||
coverage==5.0.4
|
||||
cryptography==2.0.2
|
||||
debtcollector==1.19.0
|
||||
dnspython==1.15.0
|
||||
@ -40,9 +40,6 @@ monotonic==1.4
|
||||
msgpack==0.5.6
|
||||
netaddr==0.7.19
|
||||
netifaces==0.8
|
||||
nose==1.3.7
|
||||
nosehtmloutput==0.0.3
|
||||
nosexcover==1.0.10
|
||||
oslo.config==4.0.0
|
||||
oslo.i18n==3.20.0
|
||||
oslo.log==3.22.0
|
||||
@ -57,6 +54,8 @@ pykmip==0.7.0
|
||||
Pygments==2.2.0
|
||||
pyparsing==2.2.0
|
||||
pyperclip==1.6.0
|
||||
pytest==4.6.11
|
||||
pytest-cov==2.12.1
|
||||
python-keystoneclient==2.0.0
|
||||
python-mimeparse==1.6.0
|
||||
python-subunit==1.2.0
|
||||
|
@ -8,11 +8,8 @@ alabaster===0.7.12
|
||||
pbr===5.4.5
|
||||
oslo.i18n===3.25.1
|
||||
fixtures===3.0.0
|
||||
nose===1.3.7
|
||||
nosehtmloutput===0.0.7
|
||||
sphinxcontrib-websupport===1.1.2
|
||||
ipaddress===1.0.23
|
||||
nosexcover===1.0.11
|
||||
debtcollector===1.22.0
|
||||
MarkupSafe===1.1.1
|
||||
netaddr===0.7.19
|
||||
@ -79,3 +76,5 @@ setuptools===44.1.1
|
||||
pycadf===2.10.0
|
||||
smmap===3.0.5
|
||||
PasteDeploy==2.1.1
|
||||
pytest==4.6.11
|
||||
pytest-cov==2.12.1
|
||||
|
@ -40,9 +40,6 @@ mock==4.0.3
|
||||
msgpack==1.0.3
|
||||
netaddr==0.8.0
|
||||
netifaces==0.11.0
|
||||
nose==1.3.7
|
||||
nosehtmloutput==0.0.7
|
||||
nosexcover==1.0.11
|
||||
os-service-types==1.7.0
|
||||
oslo.cache==2.11.0
|
||||
oslo.config==8.8.0
|
||||
|
@ -4,10 +4,9 @@
|
||||
|
||||
# Hacking already pins down pep8, pyflakes and flake8
|
||||
hacking>=2.0,<2.1.0 # Apache-2.0
|
||||
coverage>=3.6 # Apache-2.0
|
||||
nose>=1.3.7 # LGPL
|
||||
nosexcover>=1.0.10 # BSD
|
||||
nosehtmloutput>=0.0.3 # Apache-2.0
|
||||
coverage>=5.0.4 # Apache-2.0
|
||||
pytest>=4.6.11 # MIT
|
||||
pytest-cov>=2.12.1 # MIT
|
||||
stestr>=2.0.0 # Apache-2.0
|
||||
mock>=2.0 # BSD
|
||||
python-swiftclient>=3.2.0
|
||||
|
@ -19,7 +19,7 @@ import subprocess
|
||||
import unittest
|
||||
import uuid
|
||||
|
||||
from nose import SkipTest
|
||||
from unittest import SkipTest
|
||||
import six
|
||||
from six.moves.urllib.parse import quote
|
||||
|
||||
|
@ -35,14 +35,17 @@
|
||||
- name: install python modules with pip
|
||||
pip: name={{ item }} state=present extra_args='--upgrade'
|
||||
with_items:
|
||||
# For some reason, pip on py2 isn't smart enough to prevent us
|
||||
# trying to install a too-new mock or attrs??
|
||||
- 'mock<4'
|
||||
- 'attrs<22.1.0'
|
||||
# Order matters; install constrained versions *first*, then unconstrained
|
||||
- crudini
|
||||
- eventlet
|
||||
- nose
|
||||
- pyeclib
|
||||
- pytest
|
||||
- pytest-cov
|
||||
- python-swiftclient
|
||||
# For some reason, pip on py2 isn't smart enough to prevent us
|
||||
# trying to install a too-new mock??
|
||||
- 'mock<4'
|
||||
|
||||
- name: install PasteDeploy - CentOS 7
|
||||
pip: name={{ item }} state=present extra_args='--upgrade'
|
||||
|
@ -21,6 +21,6 @@
|
||||
shell:
|
||||
cmd: |
|
||||
source ~/.bashrc
|
||||
nosetests test/probe/ --with-id || nosetests --failed
|
||||
pytest test/probe/ || pytest --last-failed test/probe/
|
||||
executable: /bin/bash
|
||||
chdir: '{{ zuul.project.src_dir }}'
|
||||
|
14
tox.ini
14
tox.ini
@ -3,13 +3,13 @@ envlist = py37,py27,pep8
|
||||
minversion = 2.3.2
|
||||
skipsdist = True
|
||||
|
||||
[pytest]
|
||||
addopts = --verbose --cov=swift --cov-branch --cov-report=html:cover --cov-report term
|
||||
|
||||
[testenv]
|
||||
usedevelop = True
|
||||
install_command = pip install -U {opts} {packages}
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
NOSE_WITH_COVERAGE=1
|
||||
NOSE_COVER_BRANCHES=1
|
||||
NOSE_COVER_HTML_DIR={toxinidir}/cover
|
||||
deps =
|
||||
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
||||
-r{toxinidir}/requirements.txt
|
||||
@ -17,7 +17,7 @@ deps =
|
||||
commands =
|
||||
find {envdir} ( -type f -o -type l ) -name "*.py[co]" -delete
|
||||
find {envdir} -type d -name "__pycache__" -delete
|
||||
bash -ec "nosetests {posargs:test/unit} --with-id || nosetests --failed"
|
||||
bash -ec "pytest {posargs:test/unit} || pytest --last-failed {posargs:test/unit}"
|
||||
allowlist_externals =
|
||||
bash
|
||||
find
|
||||
@ -27,7 +27,7 @@ passenv = SWIFT_* *_proxy
|
||||
usedevelop = False
|
||||
deps = {[testenv:py36]deps}
|
||||
commands =
|
||||
nosetests {posargs:test/s3api}
|
||||
pytest {posargs:test/s3api}
|
||||
passenv = SWIFT_* *_proxy
|
||||
|
||||
[testenv:py27]
|
||||
@ -47,10 +47,6 @@ deps = {[testenv:py36]deps}
|
||||
|
||||
[testenv:cover]
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
NOSE_WITH_COVERAGE=1
|
||||
NOSE_COVER_BRANCHES=1
|
||||
NOSE_COVER_HTML=1
|
||||
NOSE_COVER_HTML_DIR={toxinidir}/cover
|
||||
|
||||
[testenv:pep8]
|
||||
commands =
|
||||
|
Loading…
Reference in New Issue
Block a user