From e8772657911e601dba82b3ffe17f482fdcef1338 Mon Sep 17 00:00:00 2001 From: Ondrej Nosek Date: Sep 03 2020 00:38:29 +0000 Subject: Pytest replaces nosetests Nosetests tool is deprecated. Also tools supporting Python2.6 test-environment are deprecated one by one. So this was removed too. Pytest tool will run the unit tests. When 'make test' is run, all neccessary dependencies are installed by pip. Also allows executing tests with command `python setup.py test`. Added 'setuptools_scm' dependency allows prune MANIFEST.in file. JIRA: RHELCMP-1565 Signed-off-by: Ondrej Nosek --- diff --git a/.gitignore b/.gitignore index 36d84a0..7b70a9b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ py-compile *~ *.swp -/src/pyrpkg/*.py build/ dist/ *.egg-info/ @@ -13,3 +12,9 @@ dist/ .eggs .env/ .tox/ + +doc/build/ +doc/source/_static +doc/source/commands/ +doc/source/cli.rst +doc/source/man_pages.json diff --git a/MANIFEST.in b/MANIFEST.in index d712cc1..d68b745 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,9 +1,10 @@ -include COPYING README.rst git-changelog CHANGELOG.rst CONTRIBUTING -include doc/fedpkg_man_page.py -include doc/release-guide.markdown -include test/utils.py -include test/*.conf -include pip-pycurl -recursive-include conf * -include tox.ini -include requirements.txt tests-requirements.txt +global-exclude *.pyc +global-exclude __pycache__ + +exclude .gitignore + +prune doc/build +prune doc/source/commands/ +prune doc/source/_static/ +exclude doc/source/cli.rst +exclude doc/source/man_pages.json diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e8b8e3d --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +default_targets=tox +test: $(default_targets) +.PHONY: test + +tox: + @python3 -m venv .env + @.env/bin/pip install tox + @.env/bin/tox -e py27,py36,py37,flake8,flake8python2 --parallel=auto ${TOX_POSARGS} +.PHONY: tox diff --git a/README.rst b/README.rst index 60320db..dd17e33 100644 --- a/README.rst +++ b/README.rst @@ -3,11 +3,66 @@ Introduction This is the fedpkg project, which mostly is a subclass of the rpkg project. +rpkg works with Python 2.6, 2.7, 3.6, 3.7 and 3.8. + License ======= Unless otherwise specified, all files are licensed under GPLv2+. +Installation +============ + +Install from distribution packages +---------------------------------- + +fedpkg is available in Fedora and EPEL repositories. It can be installed with +package manager command. There is Python 3 package for Fedora and Python 2 +package in EPEL6/7 and Python 3 package for EPEL8. + +Install in a Fedora system:: + + sudo dnf install fedpkg + +Install in EPEL6 or EPEL7:: + + sudo yum install fedpkg + +Install in EPEL8:: + + sudo dnf install fedpkg +Contribution +============ + +You are welcome to write patches to fix or improve rpkg. All code should work +with Python 2.6, 2.7, and 3. Before you create a PR to propose your changes, +make sure + +Sign-off commit +--------------- + +Make sure to sign-off your commits by ``git commit -s``. This serves as a +confirmation that you have the right to submit your changes. See `Developer +Certificate of Origin`_ for details. + +.. _Developer Certificate of Origin: https://developercertificate.org/ + +Run Tests +--------- + +Before make a pull request, ensure local changes pass all test cases. + +Before run tests, install these packages:: + + sudo dnf install python27 python36 python37 git make gcc rpm-build \ + libcurl-devel krb5-devel openssl-devel + +To run tests simply, ``make test``. + +By default, target ``test`` runs tests with all supported Python versions. +However, if you look into ``Makefile``, there is still a target ``tox`` that +allows developer to run tests with test environments one by one. + Links ===== diff --git a/pip-pycurl b/pip-pycurl deleted file mode 100755 index b63ea3c..0000000 --- a/pip-pycurl +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -if python -c "import pycurl" &>/dev/null; then - exit 0 -fi - -# We need to build pycurl with openssl in Fedora 27, otherwise nss should be -# used. -# See also: https://fedoraproject.org/wiki/Changes/libcurlBackToOpenSSL - -dist=$(rpm --eval "%{dist}") -dist=${dist:3} - -if [ $dist -ge 27 ]; then - install_option="--with-openssl" -else - install_option="--with-nss" -fi -pip install -v -I --install-option="${install_option}" "pycurl>=7.19" diff --git a/setup.cfg b/setup.cfg index 8d7d454..a5d6e51 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,15 +1,16 @@ [aliases] -test = nosetests +test = pytest [sdist] formats = bztar -[nosetests] -verbosity = 2 -detailed-errors = 1 -with-coverage = 1 +[tool:pytest] cover-package = fedpkg -cover-erase = 1 +# additional values for 'addopts' can be: +# --cov-report html +# -ra -q +addopts = --cov=fedpkg +testpaths = test [flake8] max-line-length = 100 diff --git a/setup.py b/setup.py index dbe244f..6b732bd 100755 --- a/setup.py +++ b/setup.py @@ -54,9 +54,9 @@ setup( ('/usr/share/zsh/site-functions', ['conf/zsh-completion/_fedpkg']), ], + setup_requires=['setuptools_scm', 'pytest-runner'], install_requires=install_requires, tests_require=tests_require, - test_suite='nose.collector', entry_points={ 'console_scripts': [ @@ -75,7 +75,8 @@ setup( 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', ], ) diff --git a/tests-requirements.txt b/tests-requirements.txt index 766f8d9..6bfa30a 100644 --- a/tests-requirements.txt +++ b/tests-requirements.txt @@ -1,8 +1,8 @@ mock == 1.0.1 -nose == 1.3.7 coverage<5.0.0 -nose-cov cccolutils gitpython freezegun rpm +pytest +pytest-cov diff --git a/tox.ini b/tox.ini index efbfcc0..a275899 100644 --- a/tox.ini +++ b/tox.ini @@ -15,13 +15,7 @@ deps = -r{toxinidir}/tests-requirements.txt passenv=PYTHONPATH commands = - # Pip call is workaround. Nose is not installed in virtual environment when - # nose is already installed in system. -I parameter is vital for install. - pip install -I nose==1.3.7 - pip install -I gitpython - # pip install -I pycurl - # /usr/bin/which nosetests-3 - python -m nose --exe --with-cov --cov-report html --cov-config setup.cfg --cov fedpkg test/ {posargs} + python -m pytest {posargs} setenv= PYCURL_SSL_LIBRARY=openssl @@ -31,4 +25,6 @@ deps = flake8 commands = python -m flake8 fedpkg/ test/ [testenv:flake8python2] -{[testenv:flake8]} +sitepackages = False +deps = flake8 +commands = python -m flake8 fedpkg/ test/