File python-python-subunit.spec of Package python-python-subunit.15928

#
# spec file for package python-python-subunit
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name:           python-python-subunit
Version:        1.3.0
Release:        0
Summary:        Python implementation of subunit test streaming protocol
License:        Apache-2.0 OR BSD-3-Clause
Group:          Development/Languages/Python
URL:            https://launchpad.net/subunit
Source:         https://files.pythonhosted.org/packages/source/p/python-subunit/python-subunit-%{version}.tar.gz
Source99:       %{name}-rpmlintrc
# PATCH-FIX-OPENSUSE speilicke@suse.com -- Filters are installed in /usr/bin.
Patch0:         python-subunit-filter-path.patch
BuildRequires:  %{python_module fixtures}
BuildRequires:  %{python_module setuptools}
# SECTION test requirements
BuildRequires:  %{python_module testscenarios}
BuildRequires:  %{python_module testtools >= 0.9.34}
BuildRequires:  %{python_module unittest2}
# /SECTION
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
Requires:       python-extras
Requires:       python-testtools >= 0.9.34
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildArch:      noarch
%python_subpackages

%description
Subunit is a streaming protocol for test results. The protocol is human
readable. The components of the protocol conceptually fit into the xUnit
TestCase->TestResult interaction.

Subunit comes with command line filters to process a subunit stream and
language bindings for python, C, C++ and shell.

%prep
%setup -q -n python-subunit-%{version}
%patch0 -p1
# Remove shebang from non-executable files
sed -i -e "1d" python/subunit/run.py

%build
%python_build

%install
%python_install
#NOTE(saschpe): The testsuite demands executables:
%{python_expand chmod +x %{buildroot}%{$python_sitelib}/subunit/tests/sample-*.py
 find %{buildroot}%{$python_sitelib}/subunit/tests/ -type f -name "sample-*.py" -exec sed -i "s|#!%{_bindir}/env python|#!%__$python|" {} \;
 $python -m compileall -d %{$python_sitelib} %{buildroot}%{$python_sitelib}/subunit/tests/
 $python -O -m compileall -d %{$python_sitelib} %{buildroot}%{$python_sitelib}/subunit/tests/
 %fdupes -s %{buildroot}%{$python_sitelib}
}
for bin in subunit-2to1 subunit2csv subunit-1to2 subunit-filter subunit-ls \
    subunit-notify subunit-stats subunit-tags subunit-output subunit2gtk \
    subunit2junitxml subunit2pyunit tap2subunit subunit2disk
    do
    %python_clone -a %{buildroot}%{_bindir}/$bin
done

%check
patch -p1 -R < %{PATCH0}
export PYTHONPATH="$PWD/python"
%python_exec -m testtools.run subunit.test_suite

%post
%{python_install_alternative subunit-2to1 subunit2csv subunit-1to2 subunit-filter subunit-ls
    subunit-notify subunit-stats subunit-tags subunit-output subunit2gtk
    subunit2junitxml subunit2pyunit tap2subunit subunit2disk}

%postun
%python_uninstall_alternative subunit-2to1

%files %{python_files}
%doc README.rst NEWS
%python_alternative %{_bindir}/subunit2csv
%python_alternative %{_bindir}/subunit-2to1
%python_alternative %{_bindir}/subunit-1to2
%python_alternative %{_bindir}/subunit-filter
%python_alternative %{_bindir}/subunit-ls
%python_alternative %{_bindir}/subunit-notify
%python_alternative %{_bindir}/subunit-stats
%python_alternative %{_bindir}/subunit-tags
%python_alternative %{_bindir}/subunit-output
%python_alternative %{_bindir}/subunit2gtk
%python_alternative %{_bindir}/subunit2junitxml
%python_alternative %{_bindir}/subunit2pyunit
%python_alternative %{_bindir}/tap2subunit
%python_alternative %{_bindir}/subunit2disk
%{python_sitelib}/subunit
%{python_sitelib}/python_subunit-%{version}-py*.egg-info

%changelog
openSUSE Build Service is sponsored by