forked from pool/python-first
Accepting request 682713 from devel:languages:python
OBS-URL: https://build.opensuse.org/request/show/682713 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-first?expand=0&rev=2
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3bb3de3582cb27071cfb514f00ed784dc444b7f96dc21e140de65fe00585c95e
|
||||
size 5325
|
||||
BIN
first-2.0.2.tar.gz
LFS
Normal file
BIN
first-2.0.2.tar.gz
LFS
Normal file
Binary file not shown.
@@ -1,3 +1,11 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 8 06:01:15 UTC 2019 - John Vandenberg <jayvdb@gmail.com>
|
||||
|
||||
- Use tests from upstream sdist
|
||||
- Update to v2.0.2
|
||||
* Package tests as part of the dist.
|
||||
* Update docs.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Mar 6 10:35:25 AM UTC 2019 - John Vandenberg <jayvdb@gmail.com>
|
||||
|
||||
|
||||
@@ -18,14 +18,13 @@
|
||||
|
||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
||||
Name: python-first
|
||||
Version: 2.0.1
|
||||
Version: 2.0.2
|
||||
Release: 0
|
||||
Summary: Return the first true value of an iterable
|
||||
License: MIT
|
||||
Group: Development/Languages/Python
|
||||
URL: http://github.com/hynek/first/
|
||||
Source: https://files.pythonhosted.org/packages/source/f/first/first-%{version}.tar.gz
|
||||
Source1: https://raw.githubusercontent.com/hynek/first/master/test_first.py
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros
|
||||
@@ -37,7 +36,6 @@ Return the first true value of an iterable.
|
||||
|
||||
%prep
|
||||
%setup -q -n first-%{version}
|
||||
cp %{SOURCE1} .
|
||||
|
||||
%build
|
||||
%python_build
|
||||
@@ -47,7 +45,7 @@ cp %{SOURCE1} .
|
||||
%python_expand %fdupes %{buildroot}%{$python_sitelib}
|
||||
|
||||
%check
|
||||
%python_expand PYTHONPATH=. $python test_first.py
|
||||
%python_expand PYTHONPATH=. $python setup.py test
|
||||
|
||||
%files %{python_files}
|
||||
%doc AUTHORS.rst README.rst
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
import unittest
|
||||
from first import first
|
||||
|
||||
|
||||
isbool = lambda x: isinstance(x, bool)
|
||||
isint = lambda x: isinstance(x, int)
|
||||
odd = lambda x: isint(x) and x % 2 != 0
|
||||
even = lambda x: isint(x) and x % 2 == 0
|
||||
is_meaning_of_life = lambda x: x == 42
|
||||
|
||||
|
||||
class TestFirst(unittest.TestCase):
|
||||
def test_empty_iterables(self):
|
||||
s = set()
|
||||
l = []
|
||||
assert first(s) is None
|
||||
assert first(l) is None
|
||||
|
||||
def test_default_value(self):
|
||||
s = set()
|
||||
l = []
|
||||
assert first(s, default=42) == 42
|
||||
assert first(l, default=3.14) == 3.14
|
||||
|
||||
l = [0, False, []]
|
||||
assert first(l, default=3.14) == 3.14
|
||||
|
||||
def test_selection(self):
|
||||
l = [(), 0, False, 3, []]
|
||||
|
||||
assert first(l, default=42) == 3
|
||||
assert first(l, key=isint) == 0
|
||||
assert first(l, key=isbool) is False
|
||||
assert first(l, key=odd) == 3
|
||||
assert first(l, key=even) == 0
|
||||
assert first(l, key=is_meaning_of_life) is None
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user