From 84bdbbd7c7143211aabb9c510018f016495090ce Mon Sep 17 00:00:00 2001 From: huangtianhua Date: Mon, 14 Feb 2022 15:48:11 +0800 Subject: [PATCH] Remove python2 and fix python3.9 test failure --- python-testtools.spec | 46 +++++++--------------------- testtools-1.8.0-py3.patch | 14 --------- testtools-2.3.0-fix-py3-compat.patch | 36 ++++++++++++++++++++++ testtools-2.3.0-fix_py39_test.patch | 14 +++++++++ 4 files changed, 61 insertions(+), 49 deletions(-) delete mode 100644 testtools-1.8.0-py3.patch create mode 100644 testtools-2.3.0-fix-py3-compat.patch create mode 100644 testtools-2.3.0-fix_py39_test.patch diff --git a/python-testtools.spec b/python-testtools.spec index bf724cb..f50f212 100644 --- a/python-testtools.spec +++ b/python-testtools.spec @@ -1,17 +1,15 @@ Name: python-testtools Version: 2.3.0 -Release: 11 +Release: 12 Summary: Extensions to the Python unit testing framework License: MIT URL: https://launchpad.net/testtools Source0: https://pypi.io/packages/source/t/testtools/testtools-%{version}.tar.gz -Patch0001: testtools-1.8.0-py3.patch -Patch0002: testtools-2.3.0-py37.patch - -BuildRequires: python2-devel python2-extras python2-mimeparse >= 0.1.4 python2-pbr python2-setuptools -BuildRequires: python2-unittest2 >= 1.0.0 python2-traceback2 python2-testscenarios python3-devel -BuildRequires: python3-extras python3-mimeparse python3-pbr python3-setuptools python3-unittest2 +Patch0001: testtools-2.3.0-py37.patch +Patch0002: testtools-2.3.0-fix-py3-compat.patch +Patch0003: testtools-2.3.0-fix_py39_test.patch +BuildRequires: python3-devel python3-extras python3-mimeparse python3-pbr python3-setuptools python3-unittest2 BuildRequires: python3-traceback2 python3-testscenarios python3-sphinx BuildArch: noarch @@ -20,15 +18,6 @@ Testtools is a set of extensions to the Python standard library's unit testing f extensions have been derived from years of experience with unit testing in Python and come from many different sources. -%package -n python2-testtools -Summary: Extensions to the Python unit testing framework -Requires: python2-extras python2-mimeparse python2-pbr python2-unittest2 >= 1.0.0 python2-traceback2 -%{?python_provide:%python_provide python2-testtools} - -%description -n python2-testtools -Testtools is a set of extensions to the Python standard library's unit testing framework. These -extensions have been derived from years of experience with unit testing in Python and come from -many different sources. %package -n python3-testtools Summary: Extensions to the Python unit testing framework @@ -41,7 +30,7 @@ many different sources. %package help Summary: Documentation for python-testtools -Requires: python2-testtools = %{version}-%{release} +Requires: python3-testtools = %{version}-%{release} Provides: bundled(jquery) %{name}-doc = %{version}-%{release} Obsoletes: %{name}-doc < %{version}-%{release} @@ -49,35 +38,19 @@ Obsoletes: %{name}-doc < %{version}-%{release} This package contains HTML documentation for python-testtools. %prep -%setup -q -n testtools-%{version} -%patch0002 -p1 -rm -rf %{py3dir} -cp -a . %{py3dir} -cd %{py3dir} -%patch0001 -p1 -find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|' -rm -f %{py3dir}/testtools/_compat2x.py %{_builddir}/testtools-%{version}/testtools/_compat3x.py +%autosetup -n testtools-%{version} -p1 +rm -rf testtools.egg-info %build -%{__python2} setup.py build PYTHONPATH=$PWD make -C doc html -cd %{py3dir} %{__python3} setup.py build %install -%{__python2} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT -cd %{py3dir} %{__python3} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT %check -make PYTHON=%{__python2} check -cd %{py3dir} make PYTHON=%{__python3} check -%files -n python2-testtools -%doc LICENSE NEWS README.rst -%{python2_sitelib}/* - %files -n python3-testtools %doc LICENSE NEWS README.rst %{python3_sitelib}/* @@ -86,6 +59,9 @@ make PYTHON=%{__python3} check %doc doc/_build/html/* %changelog +* Mon Feb 14 2022 huangtianhua - 2.3.0-12 +- Remove python2 + * Thu Feb 20 2020 lingsheng - 2.3.0-11 - Modify buildrequires to fix build fail diff --git a/testtools-1.8.0-py3.patch b/testtools-1.8.0-py3.patch deleted file mode 100644 index e97e5ac..0000000 --- a/testtools-1.8.0-py3.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- testtools-1.8.0/testtools/compat.py.py3 2015-03-11 04:19:19.000000000 +0700 -+++ testtools-1.8.0/testtools/compat.py 2015-07-28 22:54:02.537568121 +0700 -@@ -32,10 +32,7 @@ - # To let setup.py work, make this a conditional import. - linecache = try_import('linecache2') - --try: -- from testtools import _compat2x as _compat --except SyntaxError: -- from testtools import _compat3x as _compat -+from testtools import _compat3x as _compat - - reraise = _compat.reraise - diff --git a/testtools-2.3.0-fix-py3-compat.patch b/testtools-2.3.0-fix-py3-compat.patch new file mode 100644 index 0000000..52d1dae --- /dev/null +++ b/testtools-2.3.0-fix-py3-compat.patch @@ -0,0 +1,36 @@ +diff -urN testtools-2.4.0/testtools/_compat2x.py testtools-2.4.0-new/testtools/_compat2x.py +--- testtools-2.4.0/testtools/_compat2x.py 2015-11-08 01:27:33.000000000 +0800 ++++ testtools-2.4.0-new/testtools/_compat2x.py 1970-01-01 08:00:00.000000000 +0800 +@@ -1,17 +0,0 @@ +-# Copyright (c) 2011 testtools developers. See LICENSE for details. +- +-"""Compatibility helpers that are valid syntax in Python 2.x. +- +-Only add things here if they *only* work in Python 2.x or are Python 2 +-alternatives to things that *only* work in Python 3.x. +-""" +- +-__all__ = [ +- 'reraise', +- ] +- +- +-def reraise(exc_class, exc_obj, exc_tb, _marker=object()): +- """Re-raise an exception received from sys.exc_info() or similar.""" +- raise exc_class, exc_obj, exc_tb +- +diff -urN testtools-2.4.0/testtools/compat.py testtools-2.4.0-new/testtools/compat.py +--- testtools-2.4.0/testtools/compat.py 2018-04-05 07:27:14.000000000 +0800 ++++ testtools-2.4.0-new/testtools/compat.py 2021-08-06 10:55:13.294527126 +0800 +@@ -33,10 +33,7 @@ + # To let setup.py work, make this a conditional import. + linecache = try_import('linecache2') + +-try: +- from testtools import _compat2x as _compat +-except SyntaxError: +- from testtools import _compat3x as _compat ++from testtools import _compat3x as _compat + + reraise = _compat.reraise + diff --git a/testtools-2.3.0-fix_py39_test.patch b/testtools-2.3.0-fix_py39_test.patch new file mode 100644 index 0000000..1fce3f1 --- /dev/null +++ b/testtools-2.3.0-fix_py39_test.patch @@ -0,0 +1,14 @@ +diff --git a/testtools/tests/test_testresult.py b/testtools/tests/test_testresult.py +index 7b0b212..fd80a20 100644 +--- a/testtools/tests/test_testresult.py ++++ b/testtools/tests/test_testresult.py +@@ -2750,6 +2750,9 @@ class TestNonAsciiResults(TestCase): + textoutput = self._setup_external_case("import bad") + self._write_module("bad", "utf-8", _u("\ufeff^ = 0 # %s\n") % text) + textoutput = self._run_external_case() ++ # Python 3.9 no longer prints the '\ufeff' ++ if sys.version_info >= (3,9): ++ textoutput = textoutput.replace('\ufeff', '') + self.assertThat( + textoutput, + MatchesRegex( -- Gitee