From 9787a407b700f18dadfb4153b3ba1375a615b73c Mon Sep 17 00:00:00 2001 From: Nejc Habjan Date: Sun, 23 Feb 2020 20:49:33 +0100 Subject: [PATCH] chore: use pytest for unit tests and coverage --- .gitignore | 5 ++++- .testr.conf | 4 ---- .travis.yml | 7 +++++++ MANIFEST.in | 2 +- test-requirements.txt | 4 ++-- tox.ini | 10 ++++++---- 6 files changed, 20 insertions(+), 12 deletions(-) delete mode 100644 .testr.conf diff --git a/.gitignore b/.gitignore index febd0f7f1..8fab15723 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,14 @@ *.pyc build/ dist/ +htmlcov/ MANIFEST .*.swp *.egg-info .idea/ +coverage.xml docs/_build -.testrepository/ +.coverage .tox +.venv/ venv/ diff --git a/.testr.conf b/.testr.conf deleted file mode 100644 index 44644a639..000000000 --- a/.testr.conf +++ /dev/null @@ -1,4 +0,0 @@ -[DEFAULT] -test_command=${PYTHON:-python} -m subunit.run discover -t ./ ./gitlab/tests $LISTOPT $IDOPTION -test_id_option=--load-list $IDFILE -test_list_option=--list diff --git a/.travis.yml b/.travis.yml index a86780e33..29355579b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -83,5 +83,12 @@ jobs: script: - pip3 install tox - tox -e py38 + - stage: test + dist: bionic + name: coverage + python: 3.8 + script: + - pip3 install tox + - tox -e cover allow_failures: - env: GITLAB_TAG=nightly diff --git a/MANIFEST.in b/MANIFEST.in index 2d1b15b11..df53d6691 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,5 @@ include COPYING AUTHORS ChangeLog.rst RELEASE_NOTES.rst requirements.txt test-requirements.txt rtd-requirements.txt -include tox.ini .testr.conf .travis.yml +include tox.ini .travis.yml recursive-include tools * recursive-include docs *j2 *.py *.rst api/*.rst Makefile make.bat recursive-include gitlab/tests/data * diff --git a/test-requirements.txt b/test-requirements.txt index 65d09d7d3..c78843606 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,9 +1,9 @@ coverage -discover -testrepository hacking>=0.9.2,<0.10 httmock jinja2 mock +pytest +pytest-cov sphinx>=1.3 sphinx_rtd_theme diff --git a/tox.ini b/tox.ini index 92d227d5d..f721ebc80 100644 --- a/tox.ini +++ b/tox.ini @@ -13,7 +13,7 @@ install_command = pip install {opts} {packages} deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt commands = - python setup.py testr --testr-args='{posargs}' + pytest gitlab/tests {posargs} [testenv:pep8] commands = @@ -40,9 +40,11 @@ commands = python setup.py build_sphinx [testenv:cover] commands = - python setup.py testr --slowest --coverage --testr-args="{posargs}" - coverage report --omit=*tests* - coverage html --omit=*tests* + pytest --cov gitlab --cov-report term --cov-report html \ + --cov-report xml gitlab/tests {posargs} + +[coverage:run] +omit = *tests* [testenv:cli_func_v4] commands = {toxinidir}/tools/functional_tests.sh -a 4