From cab34a62ff3b20689e5f997a94b22a4de64df630 Mon Sep 17 00:00:00 2001 From: Tadej Janež Date: Jun 30 2017 08:06:48 +0000 Subject: Run tests in %check Temporarily use GitHub archive download service until upstream includes tests in the release tarballs. Add appropriate BuildRequires for running the tests. Remove end-of-line encoding fixes which are no longer necessary. --- diff --git a/python-pydocstyle.spec b/python-pydocstyle.spec index 8135e0d..7b613e2 100644 --- a/python-pydocstyle.spec +++ b/python-pydocstyle.spec @@ -3,17 +3,17 @@ Name: python-%{srcname} Version: 1.1.1 -Release:0%{?dist}.1 +Release: 0%{?dist}.2 Summary: %{sum} License: MIT URL: https://github.com/PyCQA/pydocstyle/ -# NOTE: Upstream doesn't provide ordinary tarballs -Source0: https://files.pythonhosted.org/packages/source/p/%{srcname}/%{srcname}-%{version}.zip +# NOTE: Temporarily use GitHub archive download service until upstream includes +# tests in the release tarballs. +Source0: https://github.com/PyCQA/%{srcname}/archive/%{version}/%{srcname}-%{version}.tar.gz BuildArch: noarch -BuildRequires: python2-devel python3-devel %description A static analysis tool for checking compliance with Python docstring @@ -27,6 +27,14 @@ reference implementation. Summary: %{sum} %{?python_provide:%python_provide python2-%{srcname}} +BuildRequires: python2-devel +# Required for running tests +BuildRequires: python2-pytest +BuildRequires: python-pytest-pep8 +BuildRequires: python2-mock +# NOTE: pathlib is not in BuildRequires since it is only needed by Integration +# tests which are ignored on Python 2 due to reasons described below. + %description -n python2-%{srcname} A static analysis tool for checking compliance with Python docstring conventions. @@ -42,6 +50,14 @@ python3-%{srcname}. Summary: %{sum} %{?python_provide:%python_provide python3-%{srcname}} +BuildRequires: python3-devel +# Required for running tests +BuildRequires: python3-pytest +BuildRequires: python3-pytest-pep8 +BuildRequires: python3-mock +# NOTE: pathlib is not in BuildRequires since it is part of the Python standard +# library in Python 3.4+. + %description -n python3-%{srcname} A static analysis tool for checking compliance with Python docstring conventions. @@ -61,9 +77,6 @@ reference implementation. # Remove (incorrect) Python shebang from package's __main__.py file sed -i '\|/usr/bin/env|d' build/lib/pydocstyle/__main__.py -# Fix end-of-line enconding (by stripping carriage returns) of README.rst file -sed -i 's/\r$//' README.rst - %install # Must do the python2 install first because the scripts in /usr/bin are @@ -73,8 +86,42 @@ sed -i 's/\r$//' README.rst %py3_install -# NOTE: Tests are not included in the source distribution -#%%check +%check +# Run tests under Python 2 + +# NOTE: Integration tests are ignored on Python 2 since they require having the +# 'pydocstyle' and 'pep257' executables installed on the system. As described +# below, we only package Python 3 versions of these executables. +# NOTE: We need to specify the PYTHONPATH environment variable so that Python +# can find the system-installed pydocstyle package in %%{buildroot}. +PYTHONPATH="%{buildroot}%{python2_sitelib}" py.test \ + --pep8 \ + --cache-clear \ + --ignore=src/tests/test_integration.py \ + src/tests + +# Run tests under Python 3 + +# Disable "install_package" fixure for integration tests since we want the +# tests to be run against the system-installed version of the package. +# NOTE: Two following blank lines need to be deleted to prevent the PEP8 E303 +# error (too many blank lines). +sed -i '/pytestmark = pytest.mark.usefixtures("install_package")/ { N; N; d; }' \ + src/tests/test_integration.py + +# Replace 'python(2|3)*' with '%%{__python3}' in tests that run pydocstyle as +# a named Python module. +sed -E -i 's|"python(2\|3)*( -m pydocstyle)|"%{__python3}\2|' \ + src/tests/test_integration.py + +# NOTE: We need to specify the PYTHONPATH environment variable so that Python +# can find the system-installed pydocstyle package in %%{buildroot}. +# NOTE: We need to augment the PATH environment variable so that integration +# tests can find the system-installed pydocstyle executables in %%{buildroot}. +PYTHONPATH="%{buildroot}%{python3_sitelib}" PATH="$PATH:%{buildroot}%{_bindir}" py.test-3 \ + --pep8 \ + --cache-clear \ + src/tests # NOTE: There is no %%files section for the unversioned python module if we are @@ -97,5 +144,12 @@ sed -i 's/\r$//' README.rst %changelog +* Fri Apr 07 2017 Tadej Janež 1.1.1-0.2 +- Temporarily use GitHub arhive download service until upstream includes tests + in the release tarballs. +- Run tests in %%check. +- Add appropriate BuildRequires for running the tests. +- Remove end-of-line encoding fixes which are no longer necessary. + * Mon Jan 02 2017 Tadej Janež 1.1.1-0.1 - Initial package.