- Switch to pyproject macros.
- No more greedy globs in %files. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-timeout-decorator?expand=0&rev=5
This commit is contained in:
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.
|
18
python-timeout-decorator.changes
Normal file
18
python-timeout-decorator.changes
Normal file
@@ -0,0 +1,18 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 4 06:09:43 UTC 2025 - Steve Kowalik <steven.kowalik@suse.com>
|
||||
|
||||
- Switch to pyproject macros.
|
||||
- No more greedy globs in %files.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri May 12 11:54:22 UTC 2023 - Dirk Müller <dmueller@suse.com>
|
||||
|
||||
- update to 0.5.0:
|
||||
* Allow to use timeout in function kwargs even when initial
|
||||
seconds is None
|
||||
* drop support for 2.6, 3.4, 3.5 and add support for 3.7, 3.8, 3.9
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Feb 19 02:09:49 PM UTC 2020 - John Vandenberg <jayvdb@gmail.com>
|
||||
|
||||
- Initial spec for v0.4.1
|
62
python-timeout-decorator.spec
Normal file
62
python-timeout-decorator.spec
Normal file
@@ -0,0 +1,62 @@
|
||||
#
|
||||
# spec file for package python-timeout-decorator
|
||||
#
|
||||
# Copyright (c) 2025 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 https://bugs.opensuse.org/
|
||||
#
|
||||
|
||||
|
||||
Name: python-timeout-decorator
|
||||
Version: 0.5.0
|
||||
Release: 0
|
||||
Summary: Python timeout decorator
|
||||
License: MIT
|
||||
Group: Development/Languages/Python
|
||||
URL: https://github.com/pnpnpn/timeout-decorator
|
||||
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_module pip}
|
||||
BuildRequires: %{python_module pytest}
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: %{python_module wheel}
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros
|
||||
BuildArch: noarch
|
||||
%python_subpackages
|
||||
|
||||
%description
|
||||
Python timeout decorator.
|
||||
|
||||
%prep
|
||||
%setup -q -n timeout-decorator-%{version}
|
||||
cp %{SOURCE1} %{SOURCE2} .
|
||||
|
||||
%build
|
||||
%pyproject_wheel
|
||||
|
||||
%install
|
||||
%pyproject_install
|
||||
%python_expand %fdupes %{buildroot}%{$python_sitelib}
|
||||
|
||||
%check
|
||||
%pytest
|
||||
|
||||
%files %{python_files}
|
||||
%doc CHANGES.rst README.rst
|
||||
%license LICENSE.txt
|
||||
%{python_sitelib}/timeout_decorator
|
||||
%{python_sitelib}/timeout_decorator-%{version}.dist-info
|
||||
|
||||
%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.5.0.tar.gz
Normal file
3
timeout-decorator-0.5.0.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6a2f2f58db1c5b24a2cc79de6345760377ad8bdc13813f5265f6c3e63d16b3d7
|
||||
size 4754
|
Reference in New Issue
Block a user