From 5908391c95f1e6258666ad19699cf310a71870c58ae938d83fb8323ed7aa34bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=C3=A9ta=20Machov=C3=A1?= Date: Tue, 23 Feb 2021 13:43:11 +0000 Subject: [PATCH] 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 --- .gitattributes | 23 ++++++ .gitignore | 1 + LICENSE.txt | 22 ++++++ python-timeout-decorator.changes | 4 ++ python-timeout-decorator.spec | 61 ++++++++++++++++ test_timeout_decorator.py | 120 +++++++++++++++++++++++++++++++ timeout-decorator-0.4.1.tar.gz | 3 + 7 files changed, 234 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 LICENSE.txt create mode 100644 python-timeout-decorator.changes create mode 100644 python-timeout-decorator.spec create mode 100644 test_timeout_decorator.py create mode 100644 timeout-decorator-0.4.1.tar.gz diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..97a1869 --- /dev/null +++ b/LICENSE.txt @@ -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. diff --git a/python-timeout-decorator.changes b/python-timeout-decorator.changes new file mode 100644 index 0000000..3a877b4 --- /dev/null +++ b/python-timeout-decorator.changes @@ -0,0 +1,4 @@ +------------------------------------------------------------------- +Wed Feb 19 02:09:49 PM UTC 2020 - John Vandenberg + +- Initial spec for v0.4.1 diff --git a/python-timeout-decorator.spec b/python-timeout-decorator.spec new file mode 100644 index 0000000..51bf2b3 --- /dev/null +++ b/python-timeout-decorator.spec @@ -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 diff --git a/test_timeout_decorator.py b/test_timeout_decorator.py new file mode 100644 index 0000000..4afe157 --- /dev/null +++ b/test_timeout_decorator.py @@ -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() diff --git a/timeout-decorator-0.4.1.tar.gz b/timeout-decorator-0.4.1.tar.gz new file mode 100644 index 0000000..8361379 --- /dev/null +++ b/timeout-decorator-0.4.1.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1a5e276e75c1c5acbf3cdbd9b5e45d77e1f8626f93e39bd5115d68119171d3c6 +size 4771