#411 Pytest replaces nosetests
Merged 3 years ago by onosek. Opened 3 years ago by onosek.
onosek/fedpkg pytest  into  master

file modified
+6 -1
@@ -4,7 +4,6 @@ 

  py-compile

  *~

  *.swp

- /src/pyrpkg/*.py

  build/

  dist/

  *.egg-info/
@@ -13,3 +12,9 @@ 

  .eggs

  .env/

  .tox/

+ 

+ doc/build/

+ doc/source/_static

+ doc/source/commands/

+ doc/source/cli.rst

+ doc/source/man_pages.json

file modified
+10 -9
@@ -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

file added
+9
@@ -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

file modified
+55
@@ -3,11 +3,66 @@ 

  

  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

  =====

  

file removed
-19
@@ -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"

file modified
+7 -6
@@ -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

file modified
+3 -2
@@ -54,9 +54,9 @@ 

                  ('/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 @@ 

          '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',

      ],

  )

file modified
+2 -2
@@ -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

file modified
+4 -8
@@ -15,13 +15,7 @@ 

      -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 @@ 

  commands = python -m flake8 fedpkg/ test/

  

  [testenv:flake8python2]

- {[testenv:flake8]}

+ sitepackages = False

+ deps = flake8

+ commands = python -m flake8 fedpkg/ test/

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.

Added 'setuptools_scm' dependency allows to drop MANIFEST.in file.

JIRA: RHELCMP-1565

Signed-off-by: Ondrej Nosek onosek@redhat.com

In general looks good to me. If I recall correctly, in Fedora spec file python setup.py test is called. Will that work or should it be updated?

rebased onto e877265

3 years ago

Yes, code was updated to allow python setup.py test. Similar update [1] was applied to rpkg.

[1] https://pagure.io/rpkg/pull-request/516

Nice! Looks good to me.

Pull-Request has been merged by onosek

3 years ago