Accepting request 874593 from home:jayvdb:py-submit
dependency of aiomisc, which is a dep of many aio* packages. c.f. https://www.wheelodex.org/projects/timeout-decorator/rdepends/ https://www.wheelodex.org/projects/aiomisc/rdepends/ https://www.wheelodex.org/projects/aiofile/rdepends/ OBS-URL: https://build.opensuse.org/request/show/874593 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-timeout-decorator?expand=0&rev=1
This commit is contained in:
commit
5908391c95
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
## Default LFS
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.bsp filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.gem filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||
*.lz filter=lfs diff=lfs merge=lfs -text
|
||||
*.lzma filter=lfs diff=lfs merge=lfs -text
|
||||
*.obscpio filter=lfs diff=lfs merge=lfs -text
|
||||
*.oxt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.rpm filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||
*.txz filter=lfs diff=lfs merge=lfs -text
|
||||
*.whl filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.osc
|
22
LICENSE.txt
Normal file
22
LICENSE.txt
Normal file
@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012-2014 Patrick Ng
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
4
python-timeout-decorator.changes
Normal file
4
python-timeout-decorator.changes
Normal file
@ -0,0 +1,4 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Feb 19 02:09:49 PM UTC 2020 - John Vandenberg <jayvdb@gmail.com>
|
||||
|
||||
- Initial spec for v0.4.1
|
61
python-timeout-decorator.spec
Normal file
61
python-timeout-decorator.spec
Normal file
@ -0,0 +1,61 @@
|
||||
#
|
||||
# spec file for package python-timeout-decorator
|
||||
#
|
||||
# Copyright (c) 2021 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
# upon. The license for this file, and modifications and additions to the
|
||||
# file, is the same license as for the pristine package itself (unless the
|
||||
# license for the pristine package is not an Open Source License, in which
|
||||
# case the license is the MIT License). An "Open Source License" is a
|
||||
# license that conforms to the Open Source Definition (Version 1.9)
|
||||
# published by the Open Source Initiative.
|
||||
|
||||
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
||||
|
||||
|
||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
||||
Name: python-timeout-decorator
|
||||
Version: 0.4.1
|
||||
Release: 0
|
||||
License: MIT
|
||||
Summary: Python timeout decorator
|
||||
Url: https://github.com/pnpnpn/timeout-decorator
|
||||
Group: Development/Languages/Python
|
||||
Source: https://files.pythonhosted.org/packages/source/t/timeout-decorator/timeout-decorator-%{version}.tar.gz
|
||||
Source1: https://raw.githubusercontent.com/pnpnpn/timeout-decorator/master/tests/test_timeout_decorator.py
|
||||
# https://github.com/pnpnpn/timeout-decorator/issues/68
|
||||
Source2: https://raw.githubusercontent.com/pnpnpn/timeout-decorator/master/LICENSE.txt
|
||||
BuildRequires: python-rpm-macros
|
||||
BuildRequires: %{python_module pytest}
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: fdupes
|
||||
BuildArch: noarch
|
||||
|
||||
%python_subpackages
|
||||
|
||||
%description
|
||||
Python timeout decorator.
|
||||
|
||||
%prep
|
||||
%setup -q -n timeout-decorator-%{version}
|
||||
cp %{SOURCE1} %{SOURCE2} .
|
||||
|
||||
%build
|
||||
%python_build
|
||||
|
||||
%install
|
||||
%python_install
|
||||
%python_expand %fdupes %{buildroot}%{$python_sitelib}
|
||||
|
||||
%check
|
||||
# https://github.com/pnpnpn/timeout-decorator/issues/69
|
||||
%pytest -k 'not test_timeout_kwargs_with_initial_timeout_none'
|
||||
|
||||
%files %{python_files}
|
||||
%doc CHANGES.rst README.rst
|
||||
%license LICENSE.txt
|
||||
%{python_sitelib}/*
|
||||
|
||||
%changelog
|
120
test_timeout_decorator.py
Normal file
120
test_timeout_decorator.py
Normal file
@ -0,0 +1,120 @@
|
||||
"""Timeout decorator tests."""
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from timeout_decorator import timeout, TimeoutError
|
||||
|
||||
|
||||
@pytest.fixture(params=[False, True])
|
||||
def use_signals(request):
|
||||
"""Use signals for timing out or not."""
|
||||
return request.param
|
||||
|
||||
|
||||
def test_timeout_decorator_arg(use_signals):
|
||||
@timeout(1, use_signals=use_signals)
|
||||
def f():
|
||||
time.sleep(2)
|
||||
with pytest.raises(TimeoutError):
|
||||
f()
|
||||
|
||||
|
||||
def test_timeout_class_method(use_signals):
|
||||
class c():
|
||||
@timeout(1, use_signals=use_signals)
|
||||
def f(self):
|
||||
time.sleep(2)
|
||||
with pytest.raises(TimeoutError):
|
||||
c().f()
|
||||
|
||||
|
||||
def test_timeout_kwargs(use_signals):
|
||||
@timeout(3, use_signals=use_signals)
|
||||
def f():
|
||||
time.sleep(2)
|
||||
with pytest.raises(TimeoutError):
|
||||
f(timeout=1)
|
||||
|
||||
|
||||
def test_timeout_alternate_exception(use_signals):
|
||||
@timeout(3, use_signals=use_signals, timeout_exception=StopIteration)
|
||||
def f():
|
||||
time.sleep(2)
|
||||
with pytest.raises(StopIteration):
|
||||
f(timeout=1)
|
||||
|
||||
|
||||
def test_timeout_kwargs_with_initial_timeout_none(use_signals):
|
||||
@timeout(use_signals=use_signals)
|
||||
def f():
|
||||
time.sleep(2)
|
||||
with pytest.raises(TimeoutError):
|
||||
f(timeout=1)
|
||||
|
||||
|
||||
def test_timeout_no_seconds(use_signals):
|
||||
@timeout(use_signals=use_signals)
|
||||
def f():
|
||||
time.sleep(0.1)
|
||||
f()
|
||||
|
||||
|
||||
def test_timeout_partial_seconds(use_signals):
|
||||
@timeout(0.2, use_signals=use_signals)
|
||||
def f():
|
||||
time.sleep(0.5)
|
||||
with pytest.raises(TimeoutError):
|
||||
f()
|
||||
|
||||
|
||||
def test_timeout_ok(use_signals):
|
||||
@timeout(seconds=2, use_signals=use_signals)
|
||||
def f():
|
||||
time.sleep(1)
|
||||
f()
|
||||
|
||||
|
||||
def test_function_name(use_signals):
|
||||
@timeout(seconds=2, use_signals=use_signals)
|
||||
def func_name():
|
||||
pass
|
||||
|
||||
assert func_name.__name__ == 'func_name'
|
||||
|
||||
|
||||
def test_timeout_pickle_error():
|
||||
"""Test that when a pickle error occurs a timeout error is raised."""
|
||||
@timeout(seconds=1, use_signals=False)
|
||||
def f():
|
||||
time.sleep(0.1)
|
||||
|
||||
class Test(object):
|
||||
pass
|
||||
return Test()
|
||||
with pytest.raises(TimeoutError):
|
||||
f()
|
||||
|
||||
|
||||
def test_timeout_custom_exception_message():
|
||||
@timeout(seconds=1, exception_message="Custom fail message")
|
||||
def f():
|
||||
time.sleep(2)
|
||||
with pytest.raises(TimeoutError, match="Custom fail message"):
|
||||
f()
|
||||
|
||||
|
||||
def test_timeout_custom_exception_with_message():
|
||||
@timeout(seconds=1, timeout_exception=RuntimeError, exception_message="Custom fail message")
|
||||
def f():
|
||||
time.sleep(2)
|
||||
with pytest.raises(RuntimeError, match="Custom fail message"):
|
||||
f()
|
||||
|
||||
|
||||
def test_timeout_default_exception_message():
|
||||
@timeout(seconds=1)
|
||||
def f():
|
||||
time.sleep(2)
|
||||
with pytest.raises(TimeoutError, match="Timed Out"):
|
||||
f()
|
3
timeout-decorator-0.4.1.tar.gz
Normal file
3
timeout-decorator-0.4.1.tar.gz
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1a5e276e75c1c5acbf3cdbd9b5e45d77e1f8626f93e39bd5115d68119171d3c6
|
||||
size 4771
|
Loading…
Reference in New Issue
Block a user