[packages/python-blessings] New package, version 1.7

glen glen at pld-linux.org
Thu Mar 26 10:10:41 CET 2020


commit 3cc171a0e4ebf8a10a3a97545d9a002700589329
Author: Elan Ruusamäe <glen at pld-linux.org>
Date:   Thu Mar 26 11:06:35 2020 +0200

    New package, version 1.7
    
    Based on Fedora package (d9a5494)

 ...fix-tests-when-run-without-a-tty-fixes-25.patch | 54 ++++++++++++
 0002-more-fixes-for-tests-without-a-tty.patch      | 34 ++++++++
 python-blessings.spec                              | 97 ++++++++++++++++++++++
 3 files changed, 185 insertions(+)
---
diff --git a/python-blessings.spec b/python-blessings.spec
new file mode 100644
index 0000000..aa4f24d
--- /dev/null
+++ b/python-blessings.spec
@@ -0,0 +1,97 @@
+#
+# Conditional build:
+%bcond_without	tests	# unit tests
+%bcond_without	python2 # CPython 2.x module
+%bcond_without	python3 # CPython 3.x module
+
+%define		module		blessings
+%define		egg_name	blessings
+%define		pypi_name	blessings
+Summary:	Python library for terminal coloring, styling, and positioning
+Name:		python-%{module}
+Version:	1.7
+Release:	1
+License:	MIT
+Group:		Libraries/Python
+Source0:	https://files.pythonhosted.org/packages/source/b/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
+# Source0-md5:	38555a2bba0ace706aec58444368e022
+Patch1:		0001-fix-tests-when-run-without-a-tty-fixes-25.patch
+Patch2:		0002-more-fixes-for-tests-without-a-tty.patch
+URL:		https://github.com/erikrose/blessings
+%if %{with python2}
+BuildRequires:	python-modules >= 1:2.5
+BuildRequires:	python-nose
+BuildRequires:	python-setuptools
+BuildRequires:	python-six
+%endif
+%if %{with python3}
+BuildRequires:	python3-modules >= 1:3.2
+BuildRequires:	python3-nose
+BuildRequires:	python3-setuptools
+BuildRequires:	python3-six
+%endif
+Requires:	python-six
+BuildArch:	noarch
+BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+Blessings is a thin, practical wrapper around terminal coloring,
+styling, and positioning in Python.
+
+%package -n python3-%{module}
+Summary:	Python 3 library for terminal coloring, styling, and positioning
+Group:		Libraries/Python
+Requires:	python3-six
+
+%description -n python3-%{module}
+Blessings is a thin, practical wrapper around terminal coloring,
+styling, and positioning in Python.
+
+%prep
+%setup -q -n %{pypi_name}-%{version}
+%patch1 -p1
+%patch2 -p1
+rm -r blessings.egg-info
+
+%build
+%if %{with python2}
+%py_build
+%if %{with tests}
+nosetests-%{py_ver} build-2/lib
+%endif
+%endif
+%if %{with python3}
+%py3_build
+%if %{with tests}
+nosetests-%{py3_ver} build-3/lib
+%endif
+%endif
+
+%install
+rm -rf $RPM_BUILD_ROOT
+%if %{with python2}
+%py_install
+%py_postclean
+%endif
+%if %{with python3}
+%py3_install
+%endif
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%if %{with python2}
+%files
+%defattr(644,root,root,755)
+%doc README.rst LICENSE
+%{py_sitescriptdir}/%{module}
+%{py_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
+%endif
+
+%if %{with python3}
+%files -n python3-%{module}
+%defattr(644,root,root,755)
+%doc README.rst LICENSE
+%{py3_sitescriptdir}/%{module}
+%{py3_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
+%endif
diff --git a/0001-fix-tests-when-run-without-a-tty-fixes-25.patch b/0001-fix-tests-when-run-without-a-tty-fixes-25.patch
new file mode 100644
index 0000000..867fb40
--- /dev/null
+++ b/0001-fix-tests-when-run-without-a-tty-fixes-25.patch
@@ -0,0 +1,54 @@
+https://github.com/erikrose/blessings/issues/25
+
+From 919ba5d0fedf4a7c64bd22627b47d11404f41221 Mon Sep 17 00:00:00 2001
+From: Dan Callaghan <dcallagh at redhat.com>
+Date: Fri, 30 Nov 2012 14:05:04 +1000
+Subject: [PATCH 1/2] fix tests when run without a tty (fixes #25)
+
+---
+ blessings/tests.py | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/blessings/tests.py b/blessings/tests.py
+index a03eb8d..da1a71b 100644
+--- a/blessings/tests.py
++++ b/blessings/tests.py
+@@ -43,6 +43,8 @@ def test_capability():
+ 
+     """
+     t = TestTerminal()
++    if not t.is_a_tty:
++        raise SkipTest
+     sc = unicode_cap('sc')
+     eq_(t.save, sc)
+     eq_(t.save, sc)  # Make sure caching doesn't screw it up.
+@@ -64,7 +66,7 @@ def test_capability_with_forced_tty():
+ 
+ def test_parametrization():
+     """Test parametrizing a capability."""
+-    eq_(TestTerminal().cup(3, 4), unicode_parm('cup', 3, 4))
++    eq_(TestTerminal(force_styling=True).cup(3, 4), unicode_parm('cup', 3, 4))
+ 
+ 
+ def test_height_and_width():
+@@ -144,7 +146,7 @@ def on_color(num):
+ 
+     # Avoid testing red, blue, yellow, and cyan, since they might someday
+     # change depending on terminal type.
+-    t = TestTerminal()
++    t = TestTerminal(force_styling=True)
+     eq_(t.white, color(7))
+     eq_(t.green, color(2))  # Make sure it's different than white.
+     eq_(t.on_black, on_color(0))
+@@ -250,7 +252,7 @@ def test_nice_formatting_errors():
+ def test_init_descriptor_always_initted():
+     """We should be able to get a height and width even on no-tty Terminals."""
+     t = Terminal(stream=StringIO())
+-    eq_(type(t.height), int)
++    assert isinstance(t.height, int) or t.height is None
+ 
+ 
+ def test_force_styling_none():
+-- 
+2.14.4
+
diff --git a/0002-more-fixes-for-tests-without-a-tty.patch b/0002-more-fixes-for-tests-without-a-tty.patch
new file mode 100644
index 0000000..ab2ff27
--- /dev/null
+++ b/0002-more-fixes-for-tests-without-a-tty.patch
@@ -0,0 +1,34 @@
+From abbf707b7fd7328b492b1b890118795450964755 Mon Sep 17 00:00:00 2001
+From: Dan Callaghan <dcallagh at redhat.com>
+Date: Tue, 26 Jun 2018 15:51:46 +1000
+Subject: [PATCH 2/2] more fixes for tests without a tty
+
+---
+ blessings/tests.py | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/blessings/tests.py b/blessings/tests.py
+index da1a71b..1ee238b 100644
+--- a/blessings/tests.py
++++ b/blessings/tests.py
+@@ -72,6 +72,8 @@ def test_parametrization():
+ def test_height_and_width():
+     """Assert that ``height_and_width()`` returns ints."""
+     t = TestTerminal()  # kind shouldn't matter.
++    if not t.is_a_tty:
++        raise SkipTest()
+     assert isinstance(t.height, int)
+     assert isinstance(t.width, int)
+ 
+@@ -193,7 +195,7 @@ def test_number_of_colors_without_tty():
+ 
+ def test_number_of_colors_with_tty():
+     """``number_of_colors`` should work."""
+-    t = TestTerminal()
++    t = TestTerminal(force_styling=True)
+     eq_(t.number_of_colors, 256)
+ 
+ 
+-- 
+2.14.4
+
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/python-blessings.git/commitdiff/3cc171a0e4ebf8a10a3a97545d9a002700589329



More information about the pld-cvs-commit mailing list