[python] rewrite of %check: fine-grained test exclusions

dmalcolm dmalcolm at fedoraproject.org
Sat Sep 10 11:56:18 UTC 2011


commit 866e9292651403b113045cfd33d238c57cd3201e
Author: David Malcolm <dmalcolm at redhat.com>
Date:   Sat Sep 10 07:55:07 2011 -0400

    rewrite of %check: fine-grained test exclusions
    
    * Sat Sep 10 2011 David Malcolm <dmalcolm at redhat.com> - 2.7.2-10
    - rewrite of "check", introducing downstream-only hooks for skipping specific
    cases in an rpmbuild (patch 132), and fixing/skipping failing tests in a more
    fine-grained manner than before (patches 104, 133-142)

 00104-lib64-fix-for-test_install.patch             |   13 +
 00132-add-rpmbuild-hooks-to-unittest.patch         |   68 ++++
 00133-skip-test_dl.patch                           |   13 +
 00134-fix-COUNT_ALLOCS-failure-in-test_sys.patch   |   14 +
 ...p-test-within-test_weakref-in-debug-build.patch |   18 +
 ...6-skip-tests-of-seeking-stdin-in-rpmbuild.patch |   22 ++
 ...kip-distutils-tests-that-fail-in-rpmbuild.patch |   22 ++
 00138-fix-distutils-tests-in-debug-build.patch     |   68 ++++
 00139-skip-test_float-known-failure-on-arm.patch   |   11 +
 ...0-skip-test_ctypes-known-failure-on-sparc.patch |   11 +
 00141-fix-test_gc_with_COUNT_ALLOCS.patch          |   24 ++
 00142-skip-failing-pty-tests-in-rpmbuild.patch     |   22 ++
 python.spec                                        |  338 ++++++--------------
 13 files changed, 407 insertions(+), 237 deletions(-)
---
diff --git a/00104-lib64-fix-for-test_install.patch b/00104-lib64-fix-for-test_install.patch
new file mode 100644
index 0000000..7852bf6
--- /dev/null
+++ b/00104-lib64-fix-for-test_install.patch
@@ -0,0 +1,13 @@
+--- Python-2.7.2/Lib/distutils/tests/test_install.py.lib64	2011-09-08 17:51:57.851405376 -0400
++++ Python-2.7.2/Lib/distutils/tests/test_install.py	2011-09-08 18:40:46.754205096 -0400
+@@ -41,8 +41,9 @@ class InstallTestCase(support.TempdirMan
+             self.assertEqual(got, expected)
+ 
+         libdir = os.path.join(destination, "lib", "python")
++        platlibdir = os.path.join(destination, "lib64", "python")
+         check_path(cmd.install_lib, libdir)
+-        check_path(cmd.install_platlib, libdir)
++        check_path(cmd.install_platlib, platlibdir)
+         check_path(cmd.install_purelib, libdir)
+         check_path(cmd.install_headers,
+                    os.path.join(destination, "include", "python", "foopkg"))
diff --git a/00132-add-rpmbuild-hooks-to-unittest.patch b/00132-add-rpmbuild-hooks-to-unittest.patch
new file mode 100644
index 0000000..e63395f
--- /dev/null
+++ b/00132-add-rpmbuild-hooks-to-unittest.patch
@@ -0,0 +1,68 @@
+diff -up Python-2.7.2/Lib/unittest/case.py.add-rpmbuild-hooks-to-unittest Python-2.7.2/Lib/unittest/case.py
+--- Python-2.7.2/Lib/unittest/case.py.add-rpmbuild-hooks-to-unittest	2011-09-08 14:45:47.677169191 -0400
++++ Python-2.7.2/Lib/unittest/case.py	2011-09-08 16:01:36.287858159 -0400
+@@ -1,6 +1,7 @@
+ """Test case implementation"""
+ 
+ import collections
++import os
+ import sys
+ import functools
+ import difflib
+@@ -94,6 +95,43 @@ def expectedFailure(func):
+     return wrapper
+ 
+ 
++# Non-standard/downstream-only hooks for handling issues with specific test
++# cases:
++
++def _skipInRpmBuild(reason):
++    """
++    Non-standard/downstream-only decorator for marking a specific unit test
++    to be skipped when run within the %check of an rpmbuild.
++
++    Specifically, this takes effect when WITHIN_PYTHON_RPM_BUILD is set within
++    the environment, and has no effect otherwise.
++    """
++    if 'WITHIN_PYTHON_RPM_BUILD' in os.environ:
++        return skip(reason)
++    else:
++        return _id
++
++def _expectedFailureInRpmBuild(func):
++    """
++    Non-standard/downstream-only decorator for marking a specific unit test
++    as expected to fail within the %check of an rpmbuild.
++
++    Specifically, this takes effect when WITHIN_PYTHON_RPM_BUILD is set within
++    the environment, and has no effect otherwise.
++    """
++    @functools.wraps(func)
++    def wrapper(*args, **kwargs):
++        if 'WITHIN_PYTHON_RPM_BUILD' in os.environ:
++            try:
++                func(*args, **kwargs)
++            except Exception:
++                raise _ExpectedFailure(sys.exc_info())
++            raise _UnexpectedSuccess
++        else:
++            # Call directly:
++            func(*args, **kwargs)
++    return wrapper
++
+ class _AssertRaisesContext(object):
+     """A context manager used to implement TestCase.assertRaises* methods."""
+ 
+diff -up Python-2.7.2/Lib/unittest/__init__.py.add-rpmbuild-hooks-to-unittest Python-2.7.2/Lib/unittest/__init__.py
+--- Python-2.7.2/Lib/unittest/__init__.py.add-rpmbuild-hooks-to-unittest	2011-09-08 14:59:39.534112310 -0400
++++ Python-2.7.2/Lib/unittest/__init__.py	2011-09-08 15:07:09.191081562 -0400
+@@ -57,7 +57,8 @@ __unittest = True
+ 
+ from .result import TestResult
+ from .case import (TestCase, FunctionTestCase, SkipTest, skip, skipIf,
+-                   skipUnless, expectedFailure)
++                   skipUnless, expectedFailure,
++                   _skipInRpmBuild, _expectedFailureInRpmBuild)
+ from .suite import BaseTestSuite, TestSuite
+ from .loader import (TestLoader, defaultTestLoader, makeSuite, getTestCaseNames,
+                      findTestCases)
diff --git a/00133-skip-test_dl.patch b/00133-skip-test_dl.patch
new file mode 100644
index 0000000..04ad05b
--- /dev/null
+++ b/00133-skip-test_dl.patch
@@ -0,0 +1,13 @@
+diff -up Python-2.7.2/Lib/test/test_dl.py.skip-test_dl Python-2.7.2/Lib/test/test_dl.py
+--- Python-2.7.2/Lib/test/test_dl.py.skip-test_dl	2011-09-08 15:18:40.529034289 -0400
++++ Python-2.7.2/Lib/test/test_dl.py	2011-09-08 16:29:45.184742670 -0400
+@@ -13,6 +13,9 @@ sharedlibs = [
+     ('/usr/lib/libc.dylib', 'getpid'),
+     ]
+ 
++# (also, "dl" is deprecated in favor of ctypes)
++ at unittest._skipInRpmBuild('fails on 64-bit builds: '
++    'module dl requires sizeof(int) == sizeof(long) == sizeof(char*)')
+ def test_main():
+     for s, func in sharedlibs:
+         try:
diff --git a/00134-fix-COUNT_ALLOCS-failure-in-test_sys.patch b/00134-fix-COUNT_ALLOCS-failure-in-test_sys.patch
new file mode 100644
index 0000000..362145e
--- /dev/null
+++ b/00134-fix-COUNT_ALLOCS-failure-in-test_sys.patch
@@ -0,0 +1,14 @@
+--- Python-2.7.2/Lib/test/test_sys.py.mark-tests-that-fail-in-rpmbuild	2011-09-08 18:02:31.627362039 -0400
++++ Python-2.7.2/Lib/test/test_sys.py	2011-09-08 18:15:29.450308851 -0400
+@@ -734,6 +734,11 @@ class SizeofTest(unittest.TestCase):
+         # (PyTypeObject + PyNumberMethods +  PyMappingMethods +
+         #  PySequenceMethods + PyBufferProcs)
+         s = size(vh + 'P2P15Pl4PP9PP11PI') + size('41P 10P 3P 6P')
++
++        # COUNT_ALLOCS adds further fields to the end of a PyTypeObject:
++        if hasattr(sys, 'getcounts'):
++            s += size('5P')
++
+         class newstyleclass(object):
+             pass
+         check(newstyleclass, s)
diff --git a/00135-skip-test-within-test_weakref-in-debug-build.patch b/00135-skip-test-within-test_weakref-in-debug-build.patch
new file mode 100644
index 0000000..e464aa9
--- /dev/null
+++ b/00135-skip-test-within-test_weakref-in-debug-build.patch
@@ -0,0 +1,18 @@
+diff -up Python-2.7.2/Lib/test/test_weakref.py.skip-test-within-test_weakref-in-debug-build Python-2.7.2/Lib/test/test_weakref.py
+--- Python-2.7.2/Lib/test/test_weakref.py.skip-test-within-test_weakref-in-debug-build	2011-09-08 17:55:09.675392260 -0400
++++ Python-2.7.2/Lib/test/test_weakref.py	2011-09-08 17:59:08.857375903 -0400
+@@ -550,6 +550,14 @@ class ReferencesTestCase(TestBase):
+         del c1, c2, C, D
+         gc.collect()
+ 
++    # In a debug build, this fails with:
++    #   AssertionError: Lists differ: [] != ['C went away']
++    #   Second list contains 1 additional elements.
++    #   First extra element 0:
++    #   C went away
++    #   - []
++    #   + ['C went away']
++    @unittest.skipIf(hasattr(sys, 'getobjects'), 'debug build')
+     def test_callback_in_cycle_resurrection(self):
+         import gc
+ 
diff --git a/00136-skip-tests-of-seeking-stdin-in-rpmbuild.patch b/00136-skip-tests-of-seeking-stdin-in-rpmbuild.patch
new file mode 100644
index 0000000..845fb2a
--- /dev/null
+++ b/00136-skip-tests-of-seeking-stdin-in-rpmbuild.patch
@@ -0,0 +1,22 @@
+diff -up Python-2.7.2/Lib/test/test_file2k.py.skip-tests-of-seeking-stdin-in-rpmbuild Python-2.7.2/Lib/test/test_file2k.py
+--- Python-2.7.2/Lib/test/test_file2k.py.skip-tests-of-seeking-stdin-in-rpmbuild	2011-09-08 17:23:50.922520729 -0400
++++ Python-2.7.2/Lib/test/test_file2k.py	2011-09-08 17:24:41.368517277 -0400
+@@ -213,6 +213,7 @@ class OtherFileTests(unittest.TestCase):
+             else:
+                 f.close()
+ 
++    @unittest._skipInRpmBuild('seems not to raise the exception when run in Koji')
+     def testStdin(self):
+         # This causes the interpreter to exit on OSF1 v5.1.
+         if sys.platform != 'osf1V5':
+diff -up Python-2.7.2/Lib/test/test_file.py.skip-tests-of-seeking-stdin-in-rpmbuild Python-2.7.2/Lib/test/test_file.py
+--- Python-2.7.2/Lib/test/test_file.py.skip-tests-of-seeking-stdin-in-rpmbuild	2011-09-08 17:20:31.146534389 -0400
++++ Python-2.7.2/Lib/test/test_file.py	2011-09-08 17:24:45.016517030 -0400
+@@ -154,6 +154,7 @@ class OtherFileTests(unittest.TestCase):
+                 f.close()
+                 self.fail('%r is an invalid file mode' % mode)
+ 
++    @unittest._skipInRpmBuild('seems not to raise the exception when run in Koji')
+     def testStdin(self):
+         # This causes the interpreter to exit on OSF1 v5.1.
+         if sys.platform != 'osf1V5':
diff --git a/00137-skip-distutils-tests-that-fail-in-rpmbuild.patch b/00137-skip-distutils-tests-that-fail-in-rpmbuild.patch
new file mode 100644
index 0000000..b1a55cd
--- /dev/null
+++ b/00137-skip-distutils-tests-that-fail-in-rpmbuild.patch
@@ -0,0 +1,22 @@
+diff -up Python-2.7.2/Lib/distutils/tests/test_bdist_rpm.py.mark-tests-that-fail-in-rpmbuild Python-2.7.2/Lib/distutils/tests/test_bdist_rpm.py
+--- Python-2.7.2/Lib/distutils/tests/test_bdist_rpm.py.mark-tests-that-fail-in-rpmbuild	2011-09-08 17:28:19.170502386 -0400
++++ Python-2.7.2/Lib/distutils/tests/test_bdist_rpm.py	2011-09-08 17:48:40.608418864 -0400
+@@ -24,6 +24,7 @@ setup(name='foo', version='0.1', py_modu
+ 
+ """
+ 
++ at unittest._skipInRpmBuild("don't try to nest one rpm build inside another rpm build")
+ class BuildRpmTestCase(support.TempdirManager,
+                        support.LoggingSilencer,
+                        unittest.TestCase):
+diff -up Python-2.7.2/Lib/distutils/tests/test_build_ext.py.mark-tests-that-fail-in-rpmbuild Python-2.7.2/Lib/distutils/tests/test_build_ext.py
+--- Python-2.7.2/Lib/distutils/tests/test_build_ext.py.mark-tests-that-fail-in-rpmbuild	2011-09-08 16:07:25.033834312 -0400
++++ Python-2.7.2/Lib/distutils/tests/test_build_ext.py	2011-09-08 17:43:15.656441082 -0400
+@@ -69,6 +69,7 @@ class BuildExtTestCase(support.TempdirMa
+                 name, equals, value = runshared.partition('=')
+                 cmd.library_dirs = value.split(os.pathsep)
+ 
++    @unittest._skipInRpmBuild('fails when run from build dir with /usr/bin/ld: cannot find -lpython2.7')
+     @unittest.skipIf(not os.path.exists(_XX_MODULE_PATH),
+                      'xxmodule.c not found')
+     def test_build_ext(self):
diff --git a/00138-fix-distutils-tests-in-debug-build.patch b/00138-fix-distutils-tests-in-debug-build.patch
new file mode 100644
index 0000000..0bfda90
--- /dev/null
+++ b/00138-fix-distutils-tests-in-debug-build.patch
@@ -0,0 +1,68 @@
+diff -up Python-2.7.2/Lib/distutils/tests/test_build_ext.py.mark-tests-that-fail-in-rpmbuild Python-2.7.2/Lib/distutils/tests/test_build_ext.py
+--- Python-2.7.2/Lib/distutils/tests/test_build_ext.py.mark-tests-that-fail-in-rpmbuild	2011-09-08 16:07:25.033834312 -0400
++++ Python-2.7.2/Lib/distutils/tests/test_build_ext.py	2011-09-08 17:43:15.656441082 -0400
+@@ -330,6 +332,7 @@ class BuildExtTestCase(support.TempdirMa
+         self.assertEqual(lastdir, 'bar')
+ 
+     def test_ext_fullpath(self):
++        debug_ext = sysconfig.get_config_var("DEBUG_EXT")
+         ext = sysconfig.get_config_vars()['SO']
+         dist = Distribution()
+         cmd = build_ext(dist)
+@@ -337,14 +340,14 @@ class BuildExtTestCase(support.TempdirMa
+         cmd.distribution.package_dir = {'': 'src'}
+         cmd.distribution.packages = ['lxml', 'lxml.html']
+         curdir = os.getcwd()
+-        wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + ext)
++        wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + debug_ext + ext)
+         path = cmd.get_ext_fullpath('lxml.etree')
+         self.assertEqual(wanted, path)
+ 
+         # building lxml.etree not inplace
+         cmd.inplace = 0
+         cmd.build_lib = os.path.join(curdir, 'tmpdir')
+-        wanted = os.path.join(curdir, 'tmpdir', 'lxml', 'etree' + ext)
++        wanted = os.path.join(curdir, 'tmpdir', 'lxml', 'etree' + debug_ext + ext)
+         path = cmd.get_ext_fullpath('lxml.etree')
+         self.assertEqual(wanted, path)
+ 
+@@ -354,13 +357,13 @@ class BuildExtTestCase(support.TempdirMa
+         cmd.distribution.packages = ['twisted', 'twisted.runner.portmap']
+         path = cmd.get_ext_fullpath('twisted.runner.portmap')
+         wanted = os.path.join(curdir, 'tmpdir', 'twisted', 'runner',
+-                              'portmap' + ext)
++                              'portmap' + debug_ext + ext)
+         self.assertEqual(wanted, path)
+ 
+         # building twisted.runner.portmap inplace
+         cmd.inplace = 1
+         path = cmd.get_ext_fullpath('twisted.runner.portmap')
+-        wanted = os.path.join(curdir, 'twisted', 'runner', 'portmap' + ext)
++        wanted = os.path.join(curdir, 'twisted', 'runner', 'portmap' + debug_ext + ext)
+         self.assertEqual(wanted, path)
+ 
+     def test_build_ext_inplace(self):
+@@ -373,8 +376,9 @@ class BuildExtTestCase(support.TempdirMa
+         cmd.distribution.package_dir = {'': 'src'}
+         cmd.distribution.packages = ['lxml', 'lxml.html']
+         curdir = os.getcwd()
++        debug_ext = sysconfig.get_config_var("DEBUG_EXT")
+         ext = sysconfig.get_config_var("SO")
+-        wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + ext)
++        wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + debug_ext + ext)
+         path = cmd.get_ext_fullpath('lxml.etree')
+         self.assertEqual(wanted, path)
+ 
+@@ -412,10 +416,11 @@ class BuildExtTestCase(support.TempdirMa
+         dist = Distribution({'name': 'UpdateManager'})
+         cmd = build_ext(dist)
+         cmd.ensure_finalized()
++        debug_ext = sysconfig.get_config_var("DEBUG_EXT")
+         ext = sysconfig.get_config_var("SO")
+         ext_name = os.path.join('UpdateManager', 'fdsend')
+         ext_path = cmd.get_ext_fullpath(ext_name)
+-        wanted = os.path.join(cmd.build_lib, 'UpdateManager', 'fdsend' + ext)
++        wanted = os.path.join(cmd.build_lib, 'UpdateManager', 'fdsend' + debug_ext + ext)
+         self.assertEqual(ext_path, wanted)
+ 
+     def test_build_ext_path_cross_platform(self):
diff --git a/00139-skip-test_float-known-failure-on-arm.patch b/00139-skip-test_float-known-failure-on-arm.patch
new file mode 100644
index 0000000..9d0bfad
--- /dev/null
+++ b/00139-skip-test_float-known-failure-on-arm.patch
@@ -0,0 +1,11 @@
+diff -up Python-2.7.2/Lib/test/test_float.py.skip-test_float-known-failure-on-arm Python-2.7.2/Lib/test/test_float.py
+--- Python-2.7.2/Lib/test/test_float.py.skip-test_float-known-failure-on-arm	2011-09-08 19:34:09.000986128 -0400
++++ Python-2.7.2/Lib/test/test_float.py	2011-09-08 19:34:57.969982779 -0400
+@@ -1072,6 +1072,7 @@ class HexFloatTestCase(unittest.TestCase
+                     self.identical(got, expected)
+ 
+ 
++    @unittest.skip('Known failure on ARM: http://bugs.python.org/issue8265')
+     def test_from_hex(self):
+         MIN = self.MIN;
+         MAX = self.MAX;
diff --git a/00140-skip-test_ctypes-known-failure-on-sparc.patch b/00140-skip-test_ctypes-known-failure-on-sparc.patch
new file mode 100644
index 0000000..95aa41e
--- /dev/null
+++ b/00140-skip-test_ctypes-known-failure-on-sparc.patch
@@ -0,0 +1,11 @@
+diff -up Python-2.7.2/Lib/ctypes/test/test_callbacks.py.skip-test_ctypes-known-failure-on-sparc Python-2.7.2/Lib/ctypes/test/test_callbacks.py
+--- Python-2.7.2/Lib/ctypes/test/test_callbacks.py.skip-test_ctypes-known-failure-on-sparc	2011-09-08 19:42:35.541951490 -0400
++++ Python-2.7.2/Lib/ctypes/test/test_callbacks.py	2011-09-08 19:43:40.676947036 -0400
+@@ -67,6 +67,7 @@ class Callbacks(unittest.TestCase):
+         self.check_type(c_longlong, 42)
+         self.check_type(c_longlong, -42)
+ 
++    @unittest.skip('Known failure on Sparc: http://bugs.python.org/issue8314')
+     def test_ulonglong(self):
+         # test some 64-bit values, with and without msb set.
+         self.check_type(c_ulonglong, 10955412242170339782)
diff --git a/00141-fix-test_gc_with_COUNT_ALLOCS.patch b/00141-fix-test_gc_with_COUNT_ALLOCS.patch
new file mode 100644
index 0000000..d5bf3c9
--- /dev/null
+++ b/00141-fix-test_gc_with_COUNT_ALLOCS.patch
@@ -0,0 +1,24 @@
+diff -up Python-2.7.2/Lib/test/test_gc.py.fix-test_gc_with_COUNT_ALLOCS Python-2.7.2/Lib/test/test_gc.py
+--- Python-2.7.2/Lib/test/test_gc.py.fix-test_gc_with_COUNT_ALLOCS	2011-09-08 19:49:13.045924309 -0400
++++ Python-2.7.2/Lib/test/test_gc.py	2011-09-08 19:50:07.035920617 -0400
+@@ -102,11 +102,17 @@ class GCTests(unittest.TestCase):
+         del a
+         self.assertNotEqual(gc.collect(), 0)
+         del B, C
+-        self.assertNotEqual(gc.collect(), 0)
++        if hasattr(sys, 'getcounts'):
++            self.assertEqual(gc.collect(), 0)
++        else:
++            self.assertNotEqual(gc.collect(), 0)
+         A.a = A()
+         del A
+-        self.assertNotEqual(gc.collect(), 0)
+-        self.assertEqual(gc.collect(), 0)
++        if hasattr(sys, 'getcounts'):
++            self.assertEqual(gc.collect(), 0)
++        else:
++            self.assertNotEqual(gc.collect(), 0)
++            self.assertEqual(gc.collect(), 0)
+ 
+     def test_method(self):
+         # Tricky: self.__init__ is a bound method, it references the instance.
diff --git a/00142-skip-failing-pty-tests-in-rpmbuild.patch b/00142-skip-failing-pty-tests-in-rpmbuild.patch
new file mode 100644
index 0000000..414ffcd
--- /dev/null
+++ b/00142-skip-failing-pty-tests-in-rpmbuild.patch
@@ -0,0 +1,22 @@
+diff -up Python-2.7.2/Lib/test/test_openpty.py.skip-failing-pty-tests-in-rpmbuild Python-2.7.2/Lib/test/test_openpty.py
+--- Python-2.7.2/Lib/test/test_openpty.py.skip-failing-pty-tests-in-rpmbuild	2011-09-09 05:09:28.698920379 -0400
++++ Python-2.7.2/Lib/test/test_openpty.py	2011-09-09 05:10:54.805914490 -0400
+@@ -8,6 +8,7 @@ if not hasattr(os, "openpty"):
+ 
+ 
+ class OpenptyTest(unittest.TestCase):
++    @unittest._skipInRpmBuild('sometimes fails in Koji, possibly due to a mock issue (rhbz#714627)')
+     def test(self):
+         master, slave = os.openpty()
+         if not os.isatty(slave):
+diff -up Python-2.7.2/Lib/test/test_pty.py.skip-failing-pty-tests-in-rpmbuild Python-2.7.2/Lib/test/test_pty.py
+--- Python-2.7.2/Lib/test/test_pty.py.skip-failing-pty-tests-in-rpmbuild	2011-09-09 05:09:36.781919825 -0400
++++ Python-2.7.2/Lib/test/test_pty.py	2011-09-09 05:11:14.741913127 -0400
+@@ -109,6 +109,7 @@ class PtyTest(unittest.TestCase):
+         os.close(master_fd)
+ 
+ 
++    @unittest._skipInRpmBuild('sometimes fails in Koji, possibly due to a mock issue (rhbz#714627)')
+     def test_fork(self):
+         debug("calling pty.fork()")
+         pid, master_fd = pty.fork()
diff --git a/python.spec b/python.spec
index fbc987e..30eb36a 100644
--- a/python.spec
+++ b/python.spec
@@ -102,7 +102,7 @@ Summary: An interpreted, interactive, object-oriented programming language
 Name: %{python}
 # Remember to also rebase python-docs when changing this:
 Version: 2.7.2
-Release: 9%{?dist}
+Release: 10%{?dist}
 License: Python
 Group: Development/Languages
 Requires: %{python}-libs%{?_isa} = %{version}-%{release}
@@ -358,6 +358,10 @@ Patch102: python-2.7.1-lib64.patch
 # and platform-specific code go to /usr/lib64 not /usr/lib, on 64-bit archs:
 Patch103: python-2.7-lib64-sysconfig.patch
 
+# Only used when "%{_lib}" == "lib64"
+# Another lib64 fix, for distutils/tests/test_install.py; not upstream:
+Patch104: 00104-lib64-fix-for-test_install.patch
+
 # Patch the Makefile.pre.in so that the generated Makefile doesn't try to build
 # a libpythonMAJOR.MINOR.a (bug 550692):
 Patch111: python-2.7rc1-no-static-lib.patch
@@ -504,6 +508,75 @@ Patch130: python-2.7.2-add-extension-suffix-to-python-config.patch
 # (rhbz#732998)
 Patch131: python-2.7.2-disable-tests-in-test_io.patch
 
+# Add non-standard hooks to unittest for use in the "check" phase below, when
+# running selftests within the build:
+#   @unittest._skipInRpmBuild(reason)
+# for tests that hang or fail intermittently within the build environment, and:
+#   @unittest._expectedFailureInRpmBuild
+# for tests that always fail within the build environment
+#
+# The hooks only take effect if WITHIN_PYTHON_RPM_BUILD is set in the
+# environment, which we set manually in the appropriate portion of the "check"
+# phase below (and which potentially other python-* rpms could set, to reuse
+# these unittest hooks in their own "check" phases)
+Patch132: 00132-add-rpmbuild-hooks-to-unittest.patch
+
+# "dl" is deprecated, and test_dl doesn't work on 64-bit builds:
+Patch133: 00133-skip-test_dl.patch
+
+# Fix a failure in test_sys.py when configured with COUNT_ALLOCS enabled
+# Not yet sent upstream
+Patch134: 00134-fix-COUNT_ALLOCS-failure-in-test_sys.patch
+
+# Skip "test_callback_in_cycle_resurrection" in a debug build, where it fails:
+# Not yet sent upstream
+Patch135: 00135-skip-test-within-test_weakref-in-debug-build.patch
+
+# Some tests try to seek on sys.stdin, but don't work as expected when run
+# within Koji/mock; skip them within the rpm build:
+Patch136: 00136-skip-tests-of-seeking-stdin-in-rpmbuild.patch
+
+# Some tests within distutils fail when run in an rpmbuild:
+Patch137: 00137-skip-distutils-tests-that-fail-in-rpmbuild.patch
+
+# Fixup some tests within distutils to work with how debug builds are set up:
+Patch138: 00138-fix-distutils-tests-in-debug-build.patch
+
+# ARM-specific: skip known failure in test_float:
+#  http://bugs.python.org/issue8265 (rhbz#706253)
+Patch139: 00139-skip-test_float-known-failure-on-arm.patch
+
+# Sparc-specific: skip known failure in test_ctypes:
+#  http://bugs.python.org/issue8314 (rhbz#711584)
+# which appears to be a libffi bug
+Patch140: 00140-skip-test_ctypes-known-failure-on-sparc.patch
+
+# Fix test_gc's test_newinstance case when configured with COUNT_ALLOCS:
+Patch141: 00141-fix-test_gc_with_COUNT_ALLOCS.patch
+
+# Some pty tests fail when run in mock (rhbz#714627):
+Patch142: 00142-skip-failing-pty-tests-in-rpmbuild.patch
+
+# (New patches go here ^^^)
+#
+# When adding new patches to "python" and "python3" in Fedora 17 onwards,
+# please try to keep the patch numbers in-sync between the two specfiles:
+#
+#   - use the same patch number across both specfiles for conceptually-equivalent
+#     fixes, ideally with the same name
+#
+#   - when a patch is relevan to both specfiles, use the same introductory
+#     comment in both specfiles where possible (to improve "diff" output when
+#     comparing them)
+#
+#   - when a patch is only relevant for one of the two specfiles, leave a gap
+#     in the patch numbering in the other specfile, adding a comment when
+#     omitting a patch, both in the manifest section here, and in the "prep"
+#     phase below
+#
+# Hopefully this will make it easier to ensure that all relevant fixes are
+# applied to both versions.
+
 # This is the generated patch to "configure"; see the description of
 #   %{regenerate_autotooling_patch}
 # above:
@@ -715,6 +788,7 @@ rm -r Modules/zlib || exit 1
 %if "%{_lib}" == "lib64"
 %patch102 -p1 -b .lib64
 %patch103 -p1 -b .lib64-sysconfig
+%patch104 -p1
 %endif
 
 %patch10 -p1 -b .binutils-no-dep
@@ -751,6 +825,22 @@ rm -r Modules/zlib || exit 1
 %patch131 -p1
 %endif
 
+%patch132 -p1
+%patch133 -p1
+%patch134 -p1
+%patch135 -p1
+%patch136 -p1
+%patch137 -p1
+%patch138 -p1
+%ifarch %{arm}
+%patch139 -p1
+%endif
+%ifarch %{sparc}
+%patch140 -p1
+%endif
+%patch141 -p1
+%patch142 -p1
+
 # This shouldn't be necesarry, but is right now (2.2a3)
 find -name "*~" |xargs rm -f
 
@@ -1180,240 +1270,6 @@ CheckPython() {
 
   echo STARTING: CHECKING OF PYTHON FOR CONFIGURATION: $ConfName
 
-  # Notes about disabled tests:
-  #
-  # test_argparse:
-  #   fails when in a full build, but works when run standalone; seems to be
-  #   http://bugs.python.org/issue9553 (needs COLUMNS=80 in the environment)
-  #
-  # test_distutils:
-  #   fails with
-  #      /usr/bin/ld: cannot find -lpython2.7
-  #   in: test_build_ext (distutils.tests.test_build_ext.BuildExtTestCase)
-  #       test_get_outputs (distutils.tests.test_build_ext.BuildExtTestCase)
-  #
-  # test_dl: 
-  #   fails with:
-  #     <type 'exceptions.SystemError'>: module dl requires sizeof(int) ==
-  #     sizeof(long) == sizeof(char*)
-  #   on 64-bit builds, and the module is deprecated in favour of ctypes
-  #
-  # test_gdb:
-  #   very dependent on GCC version
-  #
-  # test_http*
-  #   I've seen occasional hangs in some http tests when running the test suite
-  #   inside Koji on Python 3.  For that reason I exclude them
-  #
-  # test_socket.py:
-  #   Can fail on Koji build with:
-  #     gaierror: [Errno -3] Temporary failure in name resolution
-  #
-  # test_urllib2
-  #   Can fail on Koji build with:
-  #     gaierror: [Errno -3] Temporary failure in name resolution
-  #
-  #
-  ###########################################################################
-  # TO BE INVESTIGATED:
-  ###########################################################################
-  # 
-  # test_file:
-  #   Fails in Koji with:
-  #  ======================================================================
-  #  FAIL: testStdin (test.test_file.COtherFileTests)
-  #  ----------------------------------------------------------------------
-  #  Traceback (most recent call last):
-  #    File "/builddir/build/BUILD/Python-2.7/Lib/test/test_file.py", line 160, in testStdin
-  #      self.assertRaises((IOError, ValueError), sys.stdin.seek, -1)
-  #  AssertionError: (<type 'exceptions.IOError'>, <type 'exceptions.ValueError'>) not raised
-  #  ======================================================================
-  #  FAIL: testStdin (test.test_file.PyOtherFileTests)
-  #  ----------------------------------------------------------------------
-  #  Traceback (most recent call last):
-  #    File "/builddir/build/BUILD/Python-2.7/Lib/test/test_file.py", line 160, in testStdin
-  #      self.assertRaises((IOError, ValueError), sys.stdin.seek, -1)
-  #  AssertionError: (<type 'exceptions.IOError'>, <type 'exceptions.ValueError'>) not raised
-  #  ----------------------------------------------------------------------
-  #
-  # test_file2k:
-  #   Fails in Koji on with:
-  #  ======================================================================
-  #  FAIL: testStdin (test.test_file2k.OtherFileTests)
-  #  ----------------------------------------------------------------------
-  #  Traceback (most recent call last):
-  #    File "/builddir/build/BUILD/Python-2.7/Lib/test/test_file2k.py", line 211, in testStdin
-  #      self.assertRaises(IOError, sys.stdin.seek, -1)
-  #  AssertionError: IOError not raised
-  #  ----------------------------------------------------------------------
-  #
-  # test_openpty:
-  #   Fails in Koji, possibly due to a mock issue (rhbz#714627)
-  #  ======================================================================
-  #  ERROR: test (test.test_openpty.OpenptyTest)
-  #  ----------------------------------------------------------------------
-  #  Traceback (most recent call last):
-  #    File "/builddir/build/BUILD/Python-2.7.2/Lib/test/test_openpty.py", line 12, in test
-  #      master, slave = os.openpty()
-  #  OSError: [Errno 2] No such file or directory
-  #  ----------------------------------------------------------------------
-  #
-  # test_pty:
-  #   Fails in Koji, possibly due to a mock issue (rhbz#714627)
-  #  ======================================================================
-  #  ERROR: test_fork (test.test_pty.PtyTest)
-  #  ----------------------------------------------------------------------
-  #  Traceback (most recent call last):
-  #    File "/builddir/build/BUILD/Python-2.7.2/Lib/test/test_pty.py", line 114, in test_fork
-  #      pid, master_fd = pty.fork()
-  #    File "/builddir/build/BUILD/Python-2.7.2/Lib/pty.py", line 107, in fork
-  #      master_fd, slave_fd = openpty()
-  #    File "/builddir/build/BUILD/Python-2.7.2/Lib/pty.py", line 29, in openpty
-  #      master_fd, slave_name = _open_terminal()
-  #    File "/builddir/build/BUILD/Python-2.7.2/Lib/pty.py", line 70, in _open_terminal
-  #      raise os.error, 'out of pty devices'
-  #  OSError: out of pty devices
-  #  ----------------------------------------------------------------------
-  #
-  # test_subprocess:
-  #    Fails in Koji with:
-  #  ======================================================================
-  #  ERROR: test_leaking_fds_on_error (test.test_subprocess.ProcessTestCase)
-  #  ----------------------------------------------------------------------
-  #  Traceback (most recent call last):
-  #    File "/builddir/build/BUILD/Python-2.7/Lib/test/test_subprocess.py", line 534, in test_leaking_fds_on_error
-  #      raise c.exception
-  #  OSError: [Errno 13] Permission denied
-  #  ======================================================================
-  #  ERROR: test_leaking_fds_on_error (test.test_subprocess.ProcessTestCaseNoPoll)
-  #  ----------------------------------------------------------------------
-  #  Traceback (most recent call last):
-  #    File "/builddir/build/BUILD/Python-2.7/Lib/test/test_subprocess.py", line 534, in test_leaking_fds_on_error
-  #      raise c.exception
-  #  OSError: [Errno 13] Permission denied
-  #  ----------------------------------------------------------------------
-  #
-  EXCLUDED_TESTS="test_argparse \
-      test_distutils \
-      test_dl \
-      test_gdb \
-      test_http_cookies \
-      test_httplib \
-      test_socket \
-      test_urllib2 \
-      test_file \
-      test_file2k \
-      test_openpty \
-      test_pty \
-      test_subprocess \
-  %{nil}"
-
-  #
-  # Additional architecture-specific test exclusions:
-  #
-
-  # ARM-specific test exclusions (see rhbz#706253):
-  # test_float:
-  #   This is upstream bug: http://bugs.python.org/issue8265
-  #  ======================================================================
-  #  FAIL: test_from_hex (test.test_float.HexFloatTestCase)
-  #  ----------------------------------------------------------------------
-  #  Traceback (most recent call last):
-  #    File "/builddir/build/BUILD/Python-2.7/Lib/test/test_float.py", line 1204, in test_from_hex
-  #      self.identical(fromHex('0x0.ffffffffffffd6p-1022'), MIN-3*TINY)
-  #    File "/builddir/build/BUILD/Python-2.7/Lib/test/test_float.py", line 914, in identical
-  #      self.fail('%r not identical to %r' % (x, y))
-  #  AssertionError: 2.2250738585072e-308 not identical to 2.2250738585071984e-308
-  #  ----------------------------------------------------------------------
-%ifarch %{arm}
-  EXCLUDED_TESTS="$EXCLUDED_TESTS \
-      test_float \
-  %{nil}"
-%endif
-
-
-  # Sparc-specific test exclusions (see rhbz#711584):
-  # test_ctypes:
-  #   This is upstream bug: http://bugs.python.org/issue8314
-  #   which appears to be a libffi bug
-  #  ======================================================================
-  #  FAIL: test_ulonglong (ctypes.test.test_callbacks.Callbacks)
-  #  ----------------------------------------------------------------------
-  #  Traceback (most recent call last):
-  #    File "/builddir/build/BUILD/Python-2.7.1/Lib/ctypes/test/test_callbacks.py",
-  #  line 72, in test_ulonglong
-  #      self.check_type(c_ulonglong, 10955412242170339782)
-  #    File "/builddir/build/BUILD/Python-2.7.1/Lib/ctypes/test/test_callbacks.py",
-  #  line 31, in check_type
-  #      self.assertEqual(result, arg)
-  #  AssertionError: 10955412241121898851L != 10955412242170339782L
-  #  ----------------------------------------------------------------------
-%ifarch %{sparc}
-  EXCLUDED_TESTS="$EXCLUDED_TESTS \
-      test_ctypes \
-  %{nil}"
-%endif
-
-  # Debug build shows some additional failures (to be investigated):
-  #
-  # test_gc:
-  #  ======================================================================
-  #  FAIL: test_newinstance (__main__.GCTests)
-  #  ----------------------------------------------------------------------
-  #  Traceback (most recent call last):
-  #    File "Lib/test/test_gc.py", line 105, in test_newinstance
-  #      self.assertNotEqual(gc.collect(), 0)
-  #  AssertionError: 0 == 0
-  #  
-  #  ----------------------------------------------------------------------
-  #
-  # test_sys:
-  #  ======================================================================
-  #  FAIL: test_objecttypes (__main__.SizeofTest)
-  #  ----------------------------------------------------------------------
-  #  Traceback (most recent call last):
-  #    File "Lib/test/test_sys.py", line 739, in test_objecttypes
-  #      check(newstyleclass, s)
-  #    File "Lib/test/test_sys.py", line 510, in check_sizeof
-  #      self.assertEqual(result, size, msg)
-  #  AssertionError: wrong size for <type 'type'>: got 960, expected 920
-  #  
-  #  ----------------------------------------------------------------------
-  #  which is this code:
-  #          # type
-  #          # (PyTypeObject + PyNumberMethods +  PyMappingMethods +
-  #          #  PySequenceMethods + PyBufferProcs)
-  #          s = size(vh + 'P2P15Pl4PP9PP11PI') + size('41P 10P 3P 6P')
-  #          class newstyleclass(object):
-  #              pass
-  #          check(newstyleclass, s)
-  #  
-  # test_weakref:
-  #  ======================================================================
-  #  FAIL: test_callback_in_cycle_resurrection (__main__.ReferencesTestCase)
-  #  ----------------------------------------------------------------------
-  #  Traceback (most recent call last):
-  #    File "Lib/test/test_weakref.py", line 591, in test_callback_in_cycle_resurrection
-  #      self.assertEqual(alist, ["C went away"])
-  #  AssertionError: Lists differ: [] != ['C went away']
-  #  
-  #  Second list contains 1 additional elements.
-  #  First extra element 0:
-  #  C went away
-  #  
-  #  - []
-  #  + ['C went away']
-  #  
-  #  ----------------------------------------------------------------------
-  #
-  if [ "$ConfName" = "debug"  ] ; then
-    EXCLUDED_TESTS="$EXCLUDED_TESTS \
-      test_gc \
-      test_sys \
-      test_weakref \
-    %{nil}"
-  fi
-  
   # Note that we're running the tests using the version of the code in the
   # builddir, not in the buildroot.
 
@@ -1429,8 +1285,11 @@ CheckPython() {
   fi
 %endif
 
-  # Actually invoke regrtest.py:
-  EXTRATESTOPTS="$EXTRATESTOPTS -x $EXCLUDED_TESTS" make test
+  # Actually invoke regrtest.py, setting "WITHIN_PYTHON_RPM_BUILD" so that the
+  # our non-standard decorators take effect on the relevant tests:
+  #   @unittest._skipInRpmBuild(reason)
+  #   @unittest._expectedFailureInRpmBuild
+  WITHIN_PYTHON_RPM_BUILD= EXTRATESTOPTS="$EXTRATESTOPTS" make test
 
   popd
 
@@ -1806,6 +1665,11 @@ rm -fr %{buildroot}
 # ======================================================
 
 %changelog
+* Sat Sep 10 2011 David Malcolm <dmalcolm at redhat.com> - 2.7.2-10
+- rewrite of "check", introducing downstream-only hooks for skipping specific
+cases in an rpmbuild (patch 132), and fixing/skipping failing tests in a more
+fine-grained manner than before (patches 104, 133-142)
+
 * Thu Sep  1 2011 David Malcolm <dmalcolm at redhat.com> - 2.7.2-9
 - run selftests with "--verbose"
 - disable parts of test_io on ppc (rhbz#732998)


More information about the scm-commits mailing list