[python-testtools] update to version 0.9.29
Pádraig Brady
pbrady at fedoraproject.org
Thu Feb 7 15:37:36 UTC 2013
commit 50efbbfa43549ec7e5d704e8946f830905a601d1
Author: Pádraig Brady <P at draigBrady.com>
Date: Thu Feb 7 15:35:02 2013 +0000
update to version 0.9.29
setuptools is now used, so be BuildRequire that,
and adjust the %check to run their specific teste command
Also we revert to the way extras was included in
versions <= 0.9.24 since we're not packaging the
minimal/redundant python-extras package at this time.
python-testtools.spec | 25 ++-
testtools-0.9.29-no-extras.patch | 339 ++++++++++++++++++++++++++++++++++++++
2 files changed, 356 insertions(+), 8 deletions(-)
---
diff --git a/python-testtools.spec b/python-testtools.spec
index 70707c1..ac46778 100644
--- a/python-testtools.spec
+++ b/python-testtools.spec
@@ -3,7 +3,7 @@
%endif
Name: python-testtools
-Version: 0.9.21
+Version: 0.9.29
Release: 1%{?dist}
Summary: Extensions to the Python unit testing framework
@@ -13,12 +13,15 @@ Group: Development/Tools
License: MIT
URL: https://launchpad.net/testtools
Source0: http://pypi.python.org/packages/source/t/testtools/testtools-%{version}.tar.gz
-Patch0: testtools-0.9.21-py3.patch
+Patch0: testtools-0.9.29-no-extras.patch
+Patch1: testtools-0.9.21-py3.patch
BuildArch: noarch
BuildRequires: python2-devel
+BuildRequires: python-setuptools
%if 0%{?with_python3}
BuildRequires: python3-devel
+BuildRequires: python3-setuptools
%endif
BuildRequires: python-sphinx
@@ -45,19 +48,22 @@ Group: Documentation
Requires: %{name} = %{version}-%{release}
%description doc
-This package contains HTML documentation for %{name}.
+This package contains HTML documentation for %{name}.
%prep
%setup -q -n testtools-%{version}
+# Avoid the need for a separate extras module
+%patch0 -p1 -b.extras
+
%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
# make the Python 3 build load the Python 3.x compatibility library directly
pushd %{py3dir}
-%patch0 -p1 -b.py3
+%patch1 -p1 -b.py3
popd
find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'
@@ -93,23 +99,23 @@ popd
%check
-%{__python} setup.py test
+make PYTHON=%{__python} check
%if 0%{?with_python3}
pushd %{py3dir}
-%{__python3} setup.py test
+make PYTHON=%{__python3} check
popd
%endif # with_python3
%files
%defattr(-,root,root,-)
-%doc LICENSE NEWS README
+%doc LICENSE NEWS README.rst
%{python_sitelib}/*
%if 0%{?with_python3}
%files -n python3-testtools
-%doc LICENSE NEWS README
+%doc LICENSE NEWS README.rst
%{python3_sitelib}/*
%endif
@@ -119,6 +125,9 @@ popd
%changelog
+* Thu Feb 07 2013 Pádraig Brady <pbrady at redhat.com> - 0.9.29-1
+- Update to 0.9.29
+
* Sat Oct 27 2012 Michel Alexandre Salim <michel at sojourner> - 0.9.21-1
- Update to 0.9.21
diff --git a/testtools-0.9.29-no-extras.patch b/testtools-0.9.29-no-extras.patch
new file mode 100644
index 0000000..aae435e
--- /dev/null
+++ b/testtools-0.9.29-no-extras.patch
@@ -0,0 +1,339 @@
+diff -Naur testtools-0.9.29.orig/testtools/__init__.py testtools-0.9.29/testtools/__init__.py
+--- testtools-0.9.29.orig/testtools/__init__.py 2013-02-07 10:04:53.000000000 +0000
++++ testtools-0.9.29/testtools/__init__.py 2013-02-07 15:27:51.280269001 +0000
+@@ -30,12 +30,11 @@
+ 'try_imports',
+ ]
+
+-# Compat - removal announced in 0.9.25.
+ try:
+- from extras import (
+- try_import,
+- try_imports,
+- )
++ from testtools.helpers import (
++ try_import,
++ try_imports,
++ )
+ except ImportError:
+ # Support reading __init__ for __version__ without extras, because pip does
+ # not support setup_requires.
+diff -Naur testtools-0.9.29.orig/testtools/compat.py testtools-0.9.29/testtools/compat.py
+--- testtools-0.9.29.orig/testtools/compat.py 2013-02-07 09:39:19.000000000 +0000
++++ testtools-0.9.29/testtools/compat.py 2013-02-07 15:13:56.499060500 +0000
+@@ -28,7 +28,7 @@
+ import traceback
+ import unicodedata
+
+-from extras import try_imports
++from testtools.helpers import try_imports
+
+ BytesIO = try_imports(['StringIO.StringIO', 'io.BytesIO'])
+ StringIO = try_imports(['StringIO.StringIO', 'io.StringIO'])
+diff -Naur testtools-0.9.29.orig/testtools/content.py testtools-0.9.29/testtools/content.py
+--- testtools-0.9.29.orig/testtools/content.py 2013-01-26 14:59:29.000000000 +0000
++++ testtools-0.9.29/testtools/content.py 2013-02-07 15:14:29.723569253 +0000
+@@ -17,8 +17,7 @@
+ import sys
+ import traceback
+
+-from extras import try_import
+-
++from testtools import try_import
+ from testtools.compat import _b, _format_exc_info, str_is_unicode, _u
+ from testtools.content_type import ContentType, JSON, UTF8_TEXT
+
+diff -Naur testtools-0.9.29.orig/testtools/helpers.py testtools-0.9.29/testtools/helpers.py
+--- testtools-0.9.29.orig/testtools/helpers.py 2013-01-26 14:59:29.000000000 +0000
++++ testtools-0.9.29/testtools/helpers.py 2013-02-07 15:14:42.010757452 +0000
+@@ -8,12 +8,83 @@
+
+ import sys
+
+-# Compat - removal announced in 0.9.25.
+-from extras import (
+- safe_hasattr,
+- try_import,
+- try_imports,
+- )
++
++def try_import(name, alternative=None, error_callback=None):
++ """Attempt to import ``name``. If it fails, return ``alternative``.
++
++ When supporting multiple versions of Python or optional dependencies, it
++ is useful to be able to try to import a module.
++
++ :param name: The name of the object to import, e.g. ``os.path`` or
++ ``os.path.join``.
++ :param alternative: The value to return if no module can be imported.
++ Defaults to None.
++ :param error_callback: If non-None, a callable that is passed the ImportError
++ when the module cannot be loaded.
++ """
++ module_segments = name.split('.')
++ last_error = None
++ while module_segments:
++ module_name = '.'.join(module_segments)
++ try:
++ module = __import__(module_name)
++ except ImportError:
++ last_error = sys.exc_info()[1]
++ module_segments.pop()
++ continue
++ else:
++ break
++ else:
++ if last_error is not None and error_callback is not None:
++ error_callback(last_error)
++ return alternative
++ nonexistent = object()
++ for segment in name.split('.')[1:]:
++ module = getattr(module, segment, nonexistent)
++ if module is nonexistent:
++ if last_error is not None and error_callback is not None:
++ error_callback(last_error)
++ return alternative
++ return module
++
++
++_RAISE_EXCEPTION = object()
++def try_imports(module_names, alternative=_RAISE_EXCEPTION, error_callback=None):
++ """Attempt to import modules.
++
++ Tries to import the first module in ``module_names``. If it can be
++ imported, we return it. If not, we go on to the second module and try
++ that. The process continues until we run out of modules to try. If none
++ of the modules can be imported, either raise an exception or return the
++ provided ``alternative`` value.
++
++ :param module_names: A sequence of module names to try to import.
++ :param alternative: The value to return if no module can be imported.
++ If unspecified, we raise an ImportError.
++ :param error_callback: If None, called with the ImportError for *each*
++ module that fails to load.
++ :raises ImportError: If none of the modules can be imported and no
++ alternative value was specified.
++ """
++ module_names = list(module_names)
++ for module_name in module_names:
++ module = try_import(module_name, error_callback=error_callback)
++ if module:
++ return module
++ if alternative is _RAISE_EXCEPTION:
++ raise ImportError(
++ "Could not import any of: %s" % ', '.join(module_names))
++ return alternative
++
++
++def safe_hasattr(obj, attr, _marker=object()):
++ """Does 'obj' have an attribute 'attr'?
++
++ Use this rather than built-in hasattr, as the built-in swallows exceptions
++ in some versions of Python and behaves unpredictably with respect to
++ properties.
++ """
++ return getattr(obj, attr, _marker) is not _marker
+
+
+ def map_values(function, dictionary):
+diff -Naur testtools-0.9.29.orig/testtools/testcase.py testtools-0.9.29/testtools/testcase.py
+--- testtools-0.9.29.orig/testtools/testcase.py 2013-02-07 10:04:42.000000000 +0000
++++ testtools-0.9.29/testtools/testcase.py 2013-02-07 15:26:07.273883849 +0000
+@@ -21,13 +21,12 @@
+ import types
+ import unittest
+
+-from extras import (
+- safe_hasattr,
+- try_import,
+- )
+-
+ from testtools import (
+ content,
++ try_import,
++ )
++from testtools.helpers import (
++ safe_hasattr,
+ )
+ from testtools.compat import (
+ advance_iterator,
+diff -Naur testtools-0.9.29.orig/testtools/testresult/real.py testtools-0.9.29/testtools/testresult/real.py
+--- testtools-0.9.29.orig/testtools/testresult/real.py 2013-01-26 14:59:29.000000000 +0000
++++ testtools-0.9.29/testtools/testresult/real.py 2013-02-07 15:08:56.109470678 +0000
+@@ -16,13 +16,12 @@
+ import sys
+ import unittest
+
+-from extras import safe_hasattr
+-
+ from testtools.compat import all, str_is_unicode, _u
+ from testtools.content import (
+ text_content,
+ TracebackContent,
+ )
++from testtools.helpers import safe_hasattr
+ from testtools.tags import TagContext
+
+ # From http://docs.python.org/library/datetime.html
+diff -Naur testtools-0.9.29.orig/testtools/tests/helpers.py testtools-0.9.29/testtools/tests/helpers.py
+--- testtools-0.9.29.orig/testtools/tests/helpers.py 2013-01-26 14:59:29.000000000 +0000
++++ testtools-0.9.29/testtools/tests/helpers.py 2013-02-07 15:09:37.907108211 +0000
+@@ -8,9 +8,10 @@
+
+ import sys
+
+-from extras import safe_hasattr
+-
+ from testtools import TestResult
++from testtools.helpers import (
++ safe_hasattr,
++ )
+ from testtools.content import TracebackContent
+ from testtools import runtest
+
+diff -Naur testtools-0.9.29.orig/testtools/tests/test_deferredruntest.py testtools-0.9.29/testtools/tests/test_deferredruntest.py
+--- testtools-0.9.29.orig/testtools/tests/test_deferredruntest.py 2013-01-26 14:59:29.000000000 +0000
++++ testtools-0.9.29/testtools/tests/test_deferredruntest.py 2013-02-07 15:10:03.413497435 +0000
+@@ -5,8 +5,6 @@
+ import os
+ import signal
+
+-from extras import try_import
+-
+ from testtools import (
+ skipIf,
+ TestCase,
+@@ -15,6 +13,7 @@
+ from testtools.content import (
+ text_content,
+ )
++from testtools.helpers import try_import
+ from testtools.matchers import (
+ Equals,
+ KeysEqual,
+diff -Naur testtools-0.9.29.orig/testtools/tests/test_distutilscmd.py testtools-0.9.29/testtools/tests/test_distutilscmd.py
+--- testtools-0.9.29.orig/testtools/tests/test_distutilscmd.py 2013-01-26 14:59:29.000000000 +0000
++++ testtools-0.9.29/testtools/tests/test_distutilscmd.py 2013-02-07 15:10:11.538621453 +0000
+@@ -4,13 +4,12 @@
+
+ from distutils.dist import Distribution
+
+-from extras import try_import
+-
+ from testtools.compat import (
+ _b,
+ _u,
+ BytesIO,
+ )
++from testtools.helpers import try_import
+ fixtures = try_import('fixtures')
+
+ import testtools
+diff -Naur testtools-0.9.29.orig/testtools/tests/test_fixturesupport.py testtools-0.9.29/testtools/tests/test_fixturesupport.py
+--- testtools-0.9.29.orig/testtools/tests/test_fixturesupport.py 2013-01-26 14:59:29.000000000 +0000
++++ testtools-0.9.29/testtools/tests/test_fixturesupport.py 2013-02-07 15:10:18.379725886 +0000
+@@ -2,14 +2,13 @@
+
+ import unittest
+
+-from extras import try_import
+-
+ from testtools import (
+ TestCase,
+ content,
+ content_type,
+ )
+ from testtools.compat import _b, _u
++from testtools.helpers import try_import
+ from testtools.testresult.doubles import (
+ ExtendedTestResult,
+ )
+diff -Naur testtools-0.9.29.orig/testtools/tests/test_run.py testtools-0.9.29/testtools/tests/test_run.py
+--- testtools-0.9.29.orig/testtools/tests/test_run.py 2013-01-26 14:59:29.000000000 +0000
++++ testtools-0.9.29/testtools/tests/test_run.py 2013-02-07 15:12:09.411422158 +0000
+@@ -4,7 +4,7 @@
+
+ from unittest import TestSuite
+
+-from extras import try_import
++from testtools.helpers import try_import
+ fixtures = try_import('fixtures')
+ testresources = try_import('testresources')
+
+diff -Naur testtools-0.9.29.orig/testtools/tests/test_spinner.py testtools-0.9.29/testtools/tests/test_spinner.py
+--- testtools-0.9.29.orig/testtools/tests/test_spinner.py 2013-01-26 14:59:29.000000000 +0000
++++ testtools-0.9.29/testtools/tests/test_spinner.py 2013-02-07 15:12:19.891582396 +0000
+@@ -5,12 +5,11 @@
+ import os
+ import signal
+
+-from extras import try_import
+-
+ from testtools import (
+ skipIf,
+ TestCase,
+ )
++from testtools.helpers import try_import
+ from testtools.matchers import (
+ Equals,
+ Is,
+diff -Naur testtools-0.9.29.orig/testtools/tests/test_testresult.py testtools-0.9.29/testtools/tests/test_testresult.py
+--- testtools-0.9.29.orig/testtools/tests/test_testresult.py 2013-01-26 14:59:29.000000000 +0000
++++ testtools-0.9.29/testtools/tests/test_testresult.py 2013-02-07 15:12:39.449881492 +0000
+@@ -15,8 +15,6 @@
+ from unittest import TestSuite
+ import warnings
+
+-from extras import safe_hasattr
+-
+ from testtools import (
+ ExtendedToOriginalDecorator,
+ MultiTestResult,
+@@ -46,6 +44,7 @@
+ TracebackContent,
+ )
+ from testtools.content_type import ContentType, UTF8_TEXT
++from testtools.helpers import safe_hasattr
+ from testtools.matchers import (
+ Contains,
+ DocTestMatches,
+diff -Naur testtools-0.9.29.orig/testtools/tests/test_testsuite.py testtools-0.9.29/testtools/tests/test_testsuite.py
+--- testtools-0.9.29.orig/testtools/tests/test_testsuite.py 2013-01-26 14:59:29.000000000 +0000
++++ testtools-0.9.29/testtools/tests/test_testsuite.py 2013-02-07 15:12:48.794024418 +0000
+@@ -6,14 +6,13 @@
+
+ import unittest
+
+-from extras import try_import
+-
+ from testtools import (
+ ConcurrentTestSuite,
+ iterate_tests,
+ PlaceHolder,
+ TestCase,
+ )
++from testtools.helpers import try_import
+ from testtools.testsuite import FixtureSuite, iterate_tests, sorted_tests
+ from testtools.tests.helpers import LoggingResult
+
+diff -Naur testtools-0.9.29.orig/testtools/testsuite.py testtools-0.9.29/testtools/testsuite.py
+--- testtools-0.9.29.orig/testtools/testsuite.py 2013-01-26 14:59:29.000000000 +0000
++++ testtools-0.9.29/testtools/testsuite.py 2013-02-07 15:16:50.362698459 +0000
+@@ -10,13 +10,13 @@
+ 'sorted_tests',
+ ]
+
+-import threading
+-import unittest
+-
+-from extras import safe_hasattr, try_imports
++from testtools.helpers import safe_hasattr, try_imports
+
+ Queue = try_imports(['Queue.Queue', 'queue.Queue'])
+
++import threading
++import unittest
++
+ import testtools
+
+
More information about the scm-commits
mailing list