From d20a0bc664ded20353a2c677d942e9bd6738ac47 Mon Sep 17 00:00:00 2001 From: Carl George Date: Tue, 5 Mar 2019 10:08:48 -0600 Subject: [PATCH] Run tests correctly --- python-pid.spec | 31 ++++++++++++------- ...standard-library-mock-when-available.patch | 16 ++++++++++ 2 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 use-standard-library-mock-when-available.patch diff --git a/python-pid.spec b/python-pid.spec index b37f11e..4037e78 100644 --- a/python-pid.spec +++ b/python-pid.spec @@ -12,17 +12,22 @@ PidFile can also be used as a context manager or a decorator.} %if %{defined el6} %bcond_without python2 +# nose is too old +%bcond_with python2_tests %endif %if %{defined el7} %bcond_without python2 +%bcond_without python2_tests %endif %if %{defined fedora} && 0%{?fedora} < 29 %bcond_without python2 +%bcond_without python2_tests %endif %bcond_without python3 +%bcond_without python3_tests Name: python-%{srcname} Version: 2.2.3 @@ -33,6 +38,9 @@ License: ASL 2.0 URL: https://github.com/trbs/pid Source0: %pypi_source +# https://github.com/trbs/pid/pull/23 +Patch0: use-standard-library-mock-when-available.patch + BuildArch: noarch %description %{common_description} @@ -43,7 +51,10 @@ Summary: %{summary} BuildRequires: python2-devel BuildRequires: python2-setuptools -BuildRequires: python2-nose +%if %{with python2_tests} +BuildRequires: python2-nose >= 1.0 +BuildRequires: python2-mock +%endif %{?python_provide:%python_provide python2-%{srcname}} @@ -56,7 +67,9 @@ Summary: %{summary} BuildRequires: python%{python3_pkgversion}-devel BuildRequires: python%{python3_pkgversion}-setuptools -BuildRequires: python%{python3_pkgversion}-nose +%if %{with python3_tests} +BuildRequires: python%{python3_pkgversion}-nose >= 1.0 +%endif %{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}} @@ -86,16 +99,11 @@ rm -rf %{srcname}.egg-info %endif %check -%if %{with python2} -# Skip the test suite on EL6, nose is too old -%if 0%{?rhel} <= 6 -%else -%{__python2} setup.py test +%if %{with python2_tests} +PYTHONPATH=%{buildroot}%{python2_sitelib} nosetests-%{python2_version} --verbose %endif -%endif - -%if %{with python3} -%{__python3} setup.py test +%if %{with python3_tests} +PYTHONPATH=%{buildroot}%{python3_sitelib} nosetests-%{python3_version} --verbose %endif %if %{with python2} @@ -118,6 +126,7 @@ rm -rf %{srcname}.egg-info * Tue Mar 05 2019 Carl George - 2.2.3-1 - Latest upstream - Build python3 subpackage on el6 +- Run tests correctly * Sat Feb 02 2019 Fedora Release Engineering - 2.1.1-10 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild diff --git a/use-standard-library-mock-when-available.patch b/use-standard-library-mock-when-available.patch new file mode 100644 index 0000000..d057989 --- /dev/null +++ b/use-standard-library-mock-when-available.patch @@ -0,0 +1,16 @@ +diff --git a/tests/test_pid.py b/tests/test_pid.py +index 7c57c46..e36c29e 100644 +--- a/tests/test_pid.py ++++ b/tests/test_pid.py +@@ -2,7 +2,10 @@ + import os.path + import signal + from contextlib import contextmanager +-from mock import patch ++try: ++ from unittest.mock import patch ++except ImportError: ++ from mock import patch + + import pid +