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"))
|
SRC_DIR=$(dirname $(realpath "$0"))
|
||||||
|
|
||||||
cd ${SRC_DIR}/test/probe
|
cd ${SRC_DIR}/test/probe
|
||||||
nosetests --exe $@
|
pytest $@
|
||||||
rvalue=$?
|
rvalue=$?
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
TOP_DIR=$(dirname $(realpath "$0"))
|
TOP_DIR=$(dirname $(realpath "$0"))
|
||||||
|
|
||||||
cd $TOP_DIR/test/unit
|
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=$?
|
rvalue=$?
|
||||||
rm -f .coverage
|
rm -f .coverage
|
||||||
cd -
|
cd -
|
||||||
|
15
.zuul.yaml
15
.zuul.yaml
@ -25,9 +25,6 @@
|
|||||||
vars:
|
vars:
|
||||||
tox_envlist: py27
|
tox_envlist: py27
|
||||||
python_version: 2.7
|
python_version: 2.7
|
||||||
tox_environment:
|
|
||||||
NOSE_COVER_HTML: 1
|
|
||||||
NOSE_COVER_HTML_DIR: '{toxinidir}/cover'
|
|
||||||
post-run: tools/playbooks/common/cover-post.yaml
|
post-run: tools/playbooks/common/cover-post.yaml
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
@ -52,9 +49,6 @@
|
|||||||
tox_envlist: py36
|
tox_envlist: py36
|
||||||
bindep_profile: test py36
|
bindep_profile: test py36
|
||||||
python_version: 3.6
|
python_version: 3.6
|
||||||
tox_environment:
|
|
||||||
NOSE_COVER_HTML: 1
|
|
||||||
NOSE_COVER_HTML_DIR: '{toxinidir}/cover'
|
|
||||||
post-run: tools/playbooks/common/cover-post.yaml
|
post-run: tools/playbooks/common/cover-post.yaml
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
@ -76,9 +70,6 @@
|
|||||||
tox_envlist: py37
|
tox_envlist: py37
|
||||||
bindep_profile: test py37
|
bindep_profile: test py37
|
||||||
python_version: 3.7
|
python_version: 3.7
|
||||||
tox_environment:
|
|
||||||
NOSE_COVER_HTML: 1
|
|
||||||
NOSE_COVER_HTML_DIR: '{toxinidir}/cover'
|
|
||||||
post-run: tools/playbooks/common/cover-post.yaml
|
post-run: tools/playbooks/common/cover-post.yaml
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
@ -95,9 +86,6 @@
|
|||||||
tox_envlist: py38
|
tox_envlist: py38
|
||||||
bindep_profile: test py38
|
bindep_profile: test py38
|
||||||
python_version: 3.8
|
python_version: 3.8
|
||||||
tox_environment:
|
|
||||||
NOSE_COVER_HTML: 1
|
|
||||||
NOSE_COVER_HTML_DIR: '{toxinidir}/cover'
|
|
||||||
post-run: tools/playbooks/common/cover-post.yaml
|
post-run: tools/playbooks/common/cover-post.yaml
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
@ -130,9 +118,6 @@
|
|||||||
tox_envlist: py39
|
tox_envlist: py39
|
||||||
bindep_profile: test py39
|
bindep_profile: test py39
|
||||||
python_version: 3.9
|
python_version: 3.9
|
||||||
tox_environment:
|
|
||||||
NOSE_COVER_HTML: 1
|
|
||||||
NOSE_COVER_HTML_DIR: '{toxinidir}/cover'
|
|
||||||
post-run: tools/playbooks/common/cover-post.yaml
|
post-run: tools/playbooks/common/cover-post.yaml
|
||||||
|
|
||||||
- job:
|
- 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.
|
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,
|
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
|
.. 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
|
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:
|
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``
|
credentials file can be loaded by setting the ``SWIFT_TEST_AWS_CONFIG_FILE``
|
||||||
environment variable, e.g.::
|
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::
|
.. note::
|
||||||
When using ``SWIFT_TEST_AWS_CONFIG_FILE``, the region defaults to
|
When using ``SWIFT_TEST_AWS_CONFIG_FILE``, the region defaults to
|
||||||
|
@ -11,7 +11,7 @@ cffi==1.11.5
|
|||||||
chardet==3.0.4
|
chardet==3.0.4
|
||||||
cliff==2.11.0
|
cliff==2.11.0
|
||||||
cmd2==0.8.1
|
cmd2==0.8.1
|
||||||
coverage==3.6
|
coverage==5.0.4
|
||||||
cryptography==2.0.2
|
cryptography==2.0.2
|
||||||
debtcollector==1.19.0
|
debtcollector==1.19.0
|
||||||
dnspython==1.15.0
|
dnspython==1.15.0
|
||||||
@ -40,9 +40,6 @@ monotonic==1.4
|
|||||||
msgpack==0.5.6
|
msgpack==0.5.6
|
||||||
netaddr==0.7.19
|
netaddr==0.7.19
|
||||||
netifaces==0.8
|
netifaces==0.8
|
||||||
nose==1.3.7
|
|
||||||
nosehtmloutput==0.0.3
|
|
||||||
nosexcover==1.0.10
|
|
||||||
oslo.config==4.0.0
|
oslo.config==4.0.0
|
||||||
oslo.i18n==3.20.0
|
oslo.i18n==3.20.0
|
||||||
oslo.log==3.22.0
|
oslo.log==3.22.0
|
||||||
@ -57,6 +54,8 @@ pykmip==0.7.0
|
|||||||
Pygments==2.2.0
|
Pygments==2.2.0
|
||||||
pyparsing==2.2.0
|
pyparsing==2.2.0
|
||||||
pyperclip==1.6.0
|
pyperclip==1.6.0
|
||||||
|
pytest==4.6.11
|
||||||
|
pytest-cov==2.12.1
|
||||||
python-keystoneclient==2.0.0
|
python-keystoneclient==2.0.0
|
||||||
python-mimeparse==1.6.0
|
python-mimeparse==1.6.0
|
||||||
python-subunit==1.2.0
|
python-subunit==1.2.0
|
||||||
|
@ -8,11 +8,8 @@ alabaster===0.7.12
|
|||||||
pbr===5.4.5
|
pbr===5.4.5
|
||||||
oslo.i18n===3.25.1
|
oslo.i18n===3.25.1
|
||||||
fixtures===3.0.0
|
fixtures===3.0.0
|
||||||
nose===1.3.7
|
|
||||||
nosehtmloutput===0.0.7
|
|
||||||
sphinxcontrib-websupport===1.1.2
|
sphinxcontrib-websupport===1.1.2
|
||||||
ipaddress===1.0.23
|
ipaddress===1.0.23
|
||||||
nosexcover===1.0.11
|
|
||||||
debtcollector===1.22.0
|
debtcollector===1.22.0
|
||||||
MarkupSafe===1.1.1
|
MarkupSafe===1.1.1
|
||||||
netaddr===0.7.19
|
netaddr===0.7.19
|
||||||
@ -79,3 +76,5 @@ setuptools===44.1.1
|
|||||||
pycadf===2.10.0
|
pycadf===2.10.0
|
||||||
smmap===3.0.5
|
smmap===3.0.5
|
||||||
PasteDeploy==2.1.1
|
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
|
msgpack==1.0.3
|
||||||
netaddr==0.8.0
|
netaddr==0.8.0
|
||||||
netifaces==0.11.0
|
netifaces==0.11.0
|
||||||
nose==1.3.7
|
|
||||||
nosehtmloutput==0.0.7
|
|
||||||
nosexcover==1.0.11
|
|
||||||
os-service-types==1.7.0
|
os-service-types==1.7.0
|
||||||
oslo.cache==2.11.0
|
oslo.cache==2.11.0
|
||||||
oslo.config==8.8.0
|
oslo.config==8.8.0
|
||||||
|
@ -4,10 +4,9 @@
|
|||||||
|
|
||||||
# Hacking already pins down pep8, pyflakes and flake8
|
# Hacking already pins down pep8, pyflakes and flake8
|
||||||
hacking>=2.0,<2.1.0 # Apache-2.0
|
hacking>=2.0,<2.1.0 # Apache-2.0
|
||||||
coverage>=3.6 # Apache-2.0
|
coverage>=5.0.4 # Apache-2.0
|
||||||
nose>=1.3.7 # LGPL
|
pytest>=4.6.11 # MIT
|
||||||
nosexcover>=1.0.10 # BSD
|
pytest-cov>=2.12.1 # MIT
|
||||||
nosehtmloutput>=0.0.3 # Apache-2.0
|
|
||||||
stestr>=2.0.0 # Apache-2.0
|
stestr>=2.0.0 # Apache-2.0
|
||||||
mock>=2.0 # BSD
|
mock>=2.0 # BSD
|
||||||
python-swiftclient>=3.2.0
|
python-swiftclient>=3.2.0
|
||||||
|
@ -19,7 +19,7 @@ import subprocess
|
|||||||
import unittest
|
import unittest
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from nose import SkipTest
|
from unittest import SkipTest
|
||||||
import six
|
import six
|
||||||
from six.moves.urllib.parse import quote
|
from six.moves.urllib.parse import quote
|
||||||
|
|
||||||
|
@ -35,14 +35,17 @@
|
|||||||
- name: install python modules with pip
|
- name: install python modules with pip
|
||||||
pip: name={{ item }} state=present extra_args='--upgrade'
|
pip: name={{ item }} state=present extra_args='--upgrade'
|
||||||
with_items:
|
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
|
- crudini
|
||||||
- eventlet
|
- eventlet
|
||||||
- nose
|
|
||||||
- pyeclib
|
- pyeclib
|
||||||
|
- pytest
|
||||||
|
- pytest-cov
|
||||||
- python-swiftclient
|
- 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
|
- name: install PasteDeploy - CentOS 7
|
||||||
pip: name={{ item }} state=present extra_args='--upgrade'
|
pip: name={{ item }} state=present extra_args='--upgrade'
|
||||||
|
@ -21,6 +21,6 @@
|
|||||||
shell:
|
shell:
|
||||||
cmd: |
|
cmd: |
|
||||||
source ~/.bashrc
|
source ~/.bashrc
|
||||||
nosetests test/probe/ --with-id || nosetests --failed
|
pytest test/probe/ || pytest --last-failed test/probe/
|
||||||
executable: /bin/bash
|
executable: /bin/bash
|
||||||
chdir: '{{ zuul.project.src_dir }}'
|
chdir: '{{ zuul.project.src_dir }}'
|
||||||
|
14
tox.ini
14
tox.ini
@ -3,13 +3,13 @@ envlist = py37,py27,pep8
|
|||||||
minversion = 2.3.2
|
minversion = 2.3.2
|
||||||
skipsdist = True
|
skipsdist = True
|
||||||
|
|
||||||
|
[pytest]
|
||||||
|
addopts = --verbose --cov=swift --cov-branch --cov-report=html:cover --cov-report term
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
usedevelop = True
|
usedevelop = True
|
||||||
install_command = pip install -U {opts} {packages}
|
install_command = pip install -U {opts} {packages}
|
||||||
setenv = VIRTUAL_ENV={envdir}
|
setenv = VIRTUAL_ENV={envdir}
|
||||||
NOSE_WITH_COVERAGE=1
|
|
||||||
NOSE_COVER_BRANCHES=1
|
|
||||||
NOSE_COVER_HTML_DIR={toxinidir}/cover
|
|
||||||
deps =
|
deps =
|
||||||
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
||||||
-r{toxinidir}/requirements.txt
|
-r{toxinidir}/requirements.txt
|
||||||
@ -17,7 +17,7 @@ deps =
|
|||||||
commands =
|
commands =
|
||||||
find {envdir} ( -type f -o -type l ) -name "*.py[co]" -delete
|
find {envdir} ( -type f -o -type l ) -name "*.py[co]" -delete
|
||||||
find {envdir} -type d -name "__pycache__" -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 =
|
allowlist_externals =
|
||||||
bash
|
bash
|
||||||
find
|
find
|
||||||
@ -27,7 +27,7 @@ passenv = SWIFT_* *_proxy
|
|||||||
usedevelop = False
|
usedevelop = False
|
||||||
deps = {[testenv:py36]deps}
|
deps = {[testenv:py36]deps}
|
||||||
commands =
|
commands =
|
||||||
nosetests {posargs:test/s3api}
|
pytest {posargs:test/s3api}
|
||||||
passenv = SWIFT_* *_proxy
|
passenv = SWIFT_* *_proxy
|
||||||
|
|
||||||
[testenv:py27]
|
[testenv:py27]
|
||||||
@ -47,10 +47,6 @@ deps = {[testenv:py36]deps}
|
|||||||
|
|
||||||
[testenv:cover]
|
[testenv:cover]
|
||||||
setenv = VIRTUAL_ENV={envdir}
|
setenv = VIRTUAL_ENV={envdir}
|
||||||
NOSE_WITH_COVERAGE=1
|
|
||||||
NOSE_COVER_BRANCHES=1
|
|
||||||
NOSE_COVER_HTML=1
|
|
||||||
NOSE_COVER_HTML_DIR={toxinidir}/cover
|
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
commands =
|
commands =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user