Blob Blame History Raw
%if 0%{?rhel}
%global with_python3 0
%else
%global with_python3 1
%endif

%{!?_licensedir:%global license %%doc}

%if 0%{?rhel} && 0%{?rhel} <= 6
%{!?__python2: %global __python2 /usr/bin/python2}
%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%endif

%global srcname pytest-beakerlib
%global modulename pytest_beakerlib
# Define tar version. TODO: remove with future releases.
%global tar_version 1

Name:       python-%{srcname}
Version:    0.7.1
Release:    1%{?dist}
Summary:    A pytest plugin that reports test results to the BeakerLib framework

License:    GPLv3+
URL:        https://pagure.io/python-pytest-beakerlib
Source0:    https://releases.pagure.org/%{name}/%{srcname}-%{version}-%{tar_version}.tar.gz

BuildArch:      noarch
BuildRequires:  python2-devel
BuildRequires:  python-setuptools
BuildRequires:  pytest

%if 0%{?with_python3}
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
BuildRequires:  python3-pytest
%endif

# Test requirements:
BuildRequires:  beakerlib

%description
Allows results of running a test suite under pytest to be reported to
an active BeakerLib session.


%package -n python2-%{srcname}
Summary:    %{summary}
Requires:   pytest
%{?python_provide:%python_provide python2-%{srcname}}

%description -n python2-%{srcname}
Allows results of running a test suite under pytest to be reported to
an active BeakerLib session.


%if 0%{?with_python3}
%package -n python3-%{srcname}
Summary:    %{summary}
Requires:   python3-pytest
%{?python_provide:%python_provide python3-%{srcname}}

%description -n python3-%{srcname}
Allows results of running a test suite under pytest to be reported to
an active BeakerLib session.
%endif


%prep
%setup -q -n %{srcname}-%{version}

# Doc files should not be executable.
chmod -x smoketest.sh


%build
%{__python2} setup.py build
%if 0%{?with_python3}
%py3_build
%endif


%install
%{__python2} setup.py install --skip-build --root %{buildroot}
%if 0%{?with_python3}
%py3_install
%endif


%check
. /usr/share/beakerlib/beakerlib.sh
rlJournalStart
# There are failures in smoketest output as both success
# and failure tests are being run with beakerlib plugin enabled.
PYTHON=%{__python2} bash smoketest.sh
%if 0%{?with_python3}
PYTHON=%{__python3} bash smoketest.sh
%endif


%files -n python2-%{srcname}
%license COPYING
%doc README.rst
%doc test_demo.py
%doc smoketest.sh
%{python2_sitelib}/%{modulename}-%{version}-py2.?.egg-info
%{python2_sitelib}/%{modulename}.py*

%if 0%{?with_python3}
%files -n python3-%{srcname}
%license COPYING
%doc README.rst
%doc test_demo.py
%doc smoketest.sh
%{python3_sitelib}/%{modulename}-%{version}-py%{python3_version}.egg-info
%{python3_sitelib}/%{modulename}.py
%{python3_sitelib}/__pycache__/%{modulename}.cpython-3*.py*
%endif


%changelog
* Tue Mar 21 2017 Iryna Shcherbina <ishcherb@redhat.com> - 0.7.1-1
- Update source URL and run tests with bash
- Remove python-rpm dependency as bz#1185866 was fixed

* Fri Feb 17 2017 Iryna Shcherbina <ishcherb@redhat.com> - 0.7-1
- Bump version to 0.7
- Add python2- subpackage and modernize spec file

* Tue Aug 16 2016 Scott Poore <spoore@redhat.com> - 0.6-1
- Bump version to 0.6

* Tue Aug 16 2016 Scott Poore <spoore@redhat.com> - 0.5-4
- Add support for --short-phase-name

* Mon Mar 2 2015 Petr Viktorin <encukou@gmail.com> - 0.5-3
- Don't use licence macro on RHEL 6

* Tue Jan 27 2015 Petr Viktorin <encukou@gmail.com> - 0.5-2
- Also install COPYING as a license on the Python 3 version

* Mon Jan 26 2015 Petr Viktorin <encukou@gmail.com> - 0.5-1
- Run tests
- Install COPYING as a license

* Fri Jan 9 2015 Petr Viktorin <encukou@gmail.com> - 0.4-2
- Use correct macro for python2_sitelib

* Thu Nov 13 2014 Petr Viktorin <encukou@gmail.com> - 0.4-1
- Update to upstream 0.4

* Thu Nov 13 2014 Petr Viktorin <encukou@gmail.com> - 0.3-1
- "Upstream" packaging fixes

* Thu Nov 13 2014 Petr Viktorin <encukou@gmail.com> - 0.2-3
- Update links to Fedorahosted

* Mon Nov 3 2014 Petr Viktorin <encukou@gmail.com> - 0.2-2
- initial public version of package